diff options
author | Max Kellermann <max@duempel.org> | 2009-01-03 13:44:19 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-03 13:44:19 +0100 |
commit | 2bc01440231242c8c7c0c265b575e58d35d354c5 (patch) | |
tree | a66f021595a693d5b5a73298ec66b1f07e056cbe | |
parent | 0eb1166beb05f1880a3b9af8cb79bf5b242d50e9 (diff) | |
download | mpd-2bc01440231242c8c7c0c265b575e58d35d354c5.tar.gz mpd-2bc01440231242c8c7c0c265b575e58d35d354c5.tar.xz mpd-2bc01440231242c8c7c0c265b575e58d35d354c5.zip |
client: use GLib instead of utils.h
Diffstat (limited to '')
-rw-r--r-- | src/client.c | 15 | ||||
-rw-r--r-- | src/listen.c | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/client.c b/src/client.c index b31761ba0..48a035e11 100644 --- a/src/client.c +++ b/src/client.c @@ -21,7 +21,6 @@ #include "conf.h" #include "listen.h" #include "permission.h" -#include "utils.h" #include "event_pipe.h" #include "dlist.h" #include "idle.h" @@ -33,6 +32,9 @@ #include <assert.h> #include <unistd.h> #include <string.h> +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> #ifdef WIN32 #include <ws2tcpip.h> @@ -168,7 +170,7 @@ static inline void client_set_expired(struct client *client) } if (client->fd >= 0) { - xclose(client->fd); + close(client->fd); client->fd = -1; } } @@ -187,7 +189,6 @@ static void client_init(struct client *client, int fd) client->bufferLength = 0; client->bufferPos = 0; client->fd = fd; - set_nonblocking(fd); client->channel = g_io_channel_unix_new(client->fd); client->source_id = g_io_add_watch(client->channel, G_IO_IN, @@ -202,7 +203,7 @@ static void client_init(struct client *client, int fd) client->permission = getDefaultPermissions(); - xwrite(fd, GREETING, sizeof(GREETING) - 1); + write(fd, GREETING, sizeof(GREETING) - 1); } static void free_cmd_list(GSList *list) @@ -295,11 +296,11 @@ void client_new(int fd, const struct sockaddr *addr, int uid) if (num_clients >= client_max_connections) { g_warning("Max Connections Reached!"); - xclose(fd); + close(fd); return; } - client = xcalloc(1, sizeof(*client)); + client = g_new0(struct client, 1); list_add(&client->siblings, &clients); ++num_clients; client_init(client, fd); @@ -804,7 +805,7 @@ void client_vprintf(struct client *client, const char *fmt, va_list args) /* wtf.. */ return; - buffer = xmalloc(length + 1); + buffer = g_malloc(length + 1); vsnprintf(buffer, length + 1, fmt, args); client_write(client, buffer, length); free(buffer); diff --git a/src/listen.c b/src/listen.c index a59a6aa02..a45cb6d49 100644 --- a/src/listen.c +++ b/src/listen.c @@ -293,6 +293,8 @@ listen_in_event(G_GNUC_UNUSED GIOChannel *source, fd = accept(listen_fd, &sockAddr, &socklen); if (fd >= 0) { + set_nonblocking(fd); + client_new(fd, &sockAddr, get_remote_uid(fd)); } else if (fd < 0 && errno != EINTR) { g_warning("Problems accept()'ing"); |