aboutsummaryrefslogtreecommitdiffstats
path: root/src/client.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* command: allow clients to subscribe to specific idle eventsMarc Pavot2008-11-221-17/+12
| | | | | | The client may provide the names of idle events as arguments to the "idle" command to inform MPD that it is only interested in these events.
* client: use boolMax Kellermann2008-10-311-1/+1
| | | | Return bool instead of int.
* client: don't try again after partial writeMax Kellermann2008-10-311-0/+1
| | | | | After a partial write, chances are vanishing that another write() will succeed. Don't try immediately.
* client: use GQueue instead of sllist.h for deferred_sendMax Kellermann2008-10-311-34/+42
| | | | Another custom data structore converted to GLib.
* client: use GSList instead of struct strnode for command listsMax Kellermann2008-10-311-41/+15
| | | | Replace a custom data structure with a GLib one.
* client: removed list_cacheMax Kellermann2008-10-311-34/+1
| | | | | | The list cache aims to save memory allocations, and complicates the code a bit. We should rather use GLib slices later, which are easy to use.
* command: no CamelCaseMax Kellermann2008-10-221-4/+4
| | | | Eliminate CamelCase in all public and static functions.
* client: converted permissions to unsignedMax Kellermann2008-10-171-3/+3
| | | | client->permission is a bit set, and should be unsigned.
* client: eliminate variable "left" in client_write()Max Kellermann2008-10-171-5/+5
| | | | Reduce two temporary variables to only one.
* client: fixed send bufferMax Kellermann2008-10-171-49/+4
| | | | | There is no sense in using the kernel's send buffer size (SO_SNDBUF) for MPD's send buffer. Convert it into a static buffer of 4 kB.
* client: removed CLIENT_MAX_BUFFER_LENGTHMax Kellermann2008-10-171-3/+2
| | | | | | | Use a literal in the struct declaration, and sizeof(client->buffer) everywhere else. Also shrink the buffer from 40 kB to 4 kB. The buffer must only be large enough to hold one line of input, and 4 kB is still more than enough.
* client: added assertions on the buffer pointersMax Kellermann2008-10-171-0/+6
| | | | The buffer pointers must not exceed the buffer size.
* client: read() return value is ssize_tMax Kellermann2008-10-171-2/+2
| | | | Use ssize_t instead of int.
* client: handle partial lines correctlyMax Kellermann2008-10-171-2/+2
| | | | | | Commit 6eb62e47 didn't obey partial lines correctly: when a line wasn't finished in one read, the first part was ignored when the rest arrived.
* listen, client: enable SO_PASSCRED, get client's uidMax Kellermann2008-10-151-1/+12
| | | | | Enable authentication over unix sockets. Store the client's uid in the client struct.
* idle: client command "noidle" aborts idleMax Kellermann2008-10-151-3/+21
|
* client: optimized client_input_received()Max Kellermann2008-10-151-38/+44
| | | | | | Use memchr() instead of manually traversing the input buffer. Update the client's properties after all commands have been processed. Check for buffer overflow once.
* command: added command "idle"Max Kellermann2008-10-141-1/+82
| | | | | | "idle" waits until something noteworthy happens on the server, e.g. song change, playlist modified, database updated. This allows clients to keep up to date without polling.
* don't include os_compat.hMax Kellermann2008-10-081-1/+7
| | | | | When there are standardized headers, use these instead of the bloated os_compat.h.
* client: check expired after client_process_line()Max Kellermann2008-09-171-1/+3
| | | | | | The assertion on "!client_is_expired(client)" was wrong, because writing the command response may cause the client to become expired. Replace that assertion with a check.
* client: simplified client_read()Max Kellermann2008-09-101-3/+5
| | | | Remove one comparison by changing branch order.
* client: client_input_received() returns 0Max Kellermann2008-09-101-4/+2
| | | | | | | | | Since the caller chain doesn't care about the return value (except for COMMAND_RETURN_KILL, COMMAND_RETURN_CLOSE), just return 0 if there is nothing special. This saves one local variable initialization, and one access to it. Also remove one unreachable "return 1" from client_read().
* client: check for COMMAND_RETURN_CLOSEMax Kellermann2008-09-101-15/+14
| | | | | | | Don't close the client within client_process_line(), return COMMAND_RETURN_CLOSE instead. This is the signal for the caller chain to actually close it. This makes dealing with the client pointer a lot safer, since the caller always knows whether it is still valid.
* client: renamed local variable "selret" to "ret"Max Kellermann2008-09-101-4/+4
| | | | It's easier to reuse the variable if it has a more generic name.
* client: moved CLOSE/KILL check after client_process_line()Max Kellermann2008-09-101-4/+3
| | | | Don't update client data if it is going to be closed anyway.
* command: use client_[gs]et_permission()Max Kellermann2008-09-071-3/+1
| | | | | | Don't pass a pointer to client->permission to processCommand(), better let the code in command.c use the new permission getter/setter functions.
* client: added client_[gs]et_permission()Max Kellermann2008-09-071-0/+10
| | | | | The code in command.c shouldn't mess with a pointer to client->permission. Provide an API for accessing this value.
* removed fdprintf() and client_print()Max Kellermann2008-09-071-25/+0
| | | | | | All callers of fdprintf() have been converted to client_printf() or fprintf(); it is time to remove this clumsy hack now. We can also remove client_print() which took a file descriptor as parameter.
* client: removed client_get_fd()Max Kellermann2008-09-071-8/+0
| | | | | | Now that we have removed all invocations of client_get_fd(), we can safely remove this transitional function. All access to the file descriptor is now hidden behind the interface declared in client.h.
* command: added command_success() and command_error()Max Kellermann2008-09-071-2/+2
| | | | | | | These two functions take a client struct instead of the file descriptor. We will now begin passing the client struct around instead of a raw file descriptor (which needed a linear lookup in the client list to be useful).
* client: added client_printf()Max Kellermann2008-09-071-0/+29
| | | | | | Based on client_puts(), client_printf() is the successor of fdprintf(). As soon as all fdprintf() callers have been rewritten to use client_printf(), we can remove fdprintf().
* client: added client_write() and client_puts()Max Kellermann2008-09-071-24/+34
| | | | | | client_write() writes a buffer to the client and buffers it if required. client_puts() does the same for a C string. The next patch will add more tools which will replace fdprintf() later.
* include cleanupMax Kellermann2008-09-061-1/+0
| | | | As usual, include only headers which are really needed.
* client: don't check FD_ISSET(client->fd) on expired clientMax Kellermann2008-09-061-1/+2
| | | | | client->fd becomes -1 when the client expires. Don't use FD_ISSET() with this expired client; doing so would cause a crash due to SIGBUS.
* client: removed assert(client->fd)>=0Max Kellermann2008-09-061-4/+2
| | | | | | Since client->fd==-1 has become our "expired" flag, it may already be -1 when client_close() is called. Don't assert that it is still non-negative, and call client_set_expired() instead.
* export the function client_is_expired()Max Kellermann2008-08-291-8/+1
| | | | | | | Instead of passing the pointer to the "expired" flag to processListOfCommands(), this function should use the client API to check this flag. We can now remove the "global_expired" hack introduced recently.
* client: pass the client struct to processCommand()Max Kellermann2008-08-291-2/+10
| | | | | | | | Start exporting the client struct as an opaque struct. For now, pass it only to processCommand() and processListOfCommands(), and provide a function to extract the socket handle. Later, we will propagate the pointer to all command implementations, and of course to client_print() etc.
* client: check "expired" after command executionMax Kellermann2008-08-291-7/+14
| | | | | | The old code tried to write a response to the client, without even checking if it was already closed. Now that we have added more assertions, these may fail... perform the "expired" check earlier.
* client: added global "expired" flagMax Kellermann2008-08-291-6/+7
| | | | | | | | | | Patch bdeb8e14 ("client: moved "expired" accesses into inline function") was created under the wrong assumption that processListOfCommands() could modify the expired flag, which is not the case. Although "expired" is a non-const pointer, processListOfCommands() just reads it, using it as the break condition in a "while" loop. I will address this issue with a better overall solution, but for now provide a pointer to a global "expired" flag.
* client: removed superfluous assertionMax Kellermann2008-08-291-1/+0
| | | | | | client_defer_output() was modified so that it can create the deferred_send list. With this patch, the assertion on "deferred_send!=NULL" has become invalid. Remove it.
* client: more assertionsMax Kellermann2008-08-281-0/+6
|
* client: replace "expired" flag with fd==-1Max Kellermann2008-08-281-6/+6
| | | | Why waste 4 bytes for a flag which we can hide in another variable.
* client: moved "expired" accesses into inline functionMax Kellermann2008-08-281-13/+29
| | | | Hiding this flag allows us later to remove it easily.
* moved code to sockaddr_to_tmp_string()Max Kellermann2008-08-281-9/+17
| | | | | Unclutter the client_new() constructor by moving unrelated complex code into a separate function.
* client: no while loop in client_manager_io()Max Kellermann2008-08-281-32/+26
| | | | | | The last patch removed the "continue" directive, and now the while loop is without function. Remove it. Also make client_manager_io() return 0.
* client: select() errors are fatalMax Kellermann2008-08-281-30/+6
| | | | | | | Previously, when select() failed, we assumed that there was an invalid file descriptor in one of the client structs. Thus we tried select() one by one. This is bogus, because we should never have invalid file descriptors. Remove it, and make select() errors fatal.
* client: use client_defer_output() in client_write()Max Kellermann2008-08-281-7/+3
| | | | | Eliminate duplicated code, call client_defer_output() which we splitted from client_write_output() earlier.
* moved code to client_write()Max Kellermann2008-08-281-26/+28
| | | | | Move the second part of client_write_output() into a separate function.
* client: client_defer_output() can create the first defer bufferMax Kellermann2008-08-281-5/+5
| | | | | | client_defer_output() was designed to add new buffers to an existing deferred_send buffer. Tweak it and allow it to create a new buffer list.
* client: return early on error in client_defer_output()Max Kellermann2008-08-281-5/+7
| | | | | Exit the function when an error occurs, and move the rest of the following code one indent level left.