Mercurial > geeqie
comparison src/remote.c @ 495:c7a2471e5c4e
Introduce macros to display debug messages.
if (debug) printf(...) is now replaced by variadic macros:
DEBUG_1()
And for higher debugging levels:
DEBUG_2()
DEBUG_3()
DEBUG_4()
author | zas_ |
---|---|
date | Wed, 23 Apr 2008 20:47:19 +0000 |
parents | 48c8e49b571c |
children | fc9c8a3e1a8b |
comparison
equal
deleted
inserted
replaced
494:3bb9a8df6ee9 | 495:c7a2471e5c4e |
---|---|
95 | 95 |
96 if (condition & G_IO_HUP) | 96 if (condition & G_IO_HUP) |
97 { | 97 { |
98 rc->clients = g_list_remove(rc->clients, client); | 98 rc->clients = g_list_remove(rc->clients, client); |
99 | 99 |
100 if (debug) | 100 DEBUG_1("HUP detected, closing client.\nclient count %d\n", g_list_length(rc->clients)); |
101 { | 101 |
102 printf("HUP detected, closing client.\n"); | |
103 printf("client count %d\n", g_list_length(rc->clients)); | |
104 } | |
105 | |
106 g_source_remove(client->channel_id); | 102 g_source_remove(client->channel_id); |
107 close(client->fd); | 103 close(client->fd); |
108 g_free(client); | 104 g_free(client); |
109 } | 105 } |
110 | 106 |
131 client->channel_id = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, G_IO_IN | G_IO_HUP, | 127 client->channel_id = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, G_IO_IN | G_IO_HUP, |
132 remote_server_client_cb, client, NULL); | 128 remote_server_client_cb, client, NULL); |
133 g_io_channel_unref(channel); | 129 g_io_channel_unref(channel); |
134 | 130 |
135 rc->clients = g_list_append(rc->clients, client); | 131 rc->clients = g_list_append(rc->clients, client); |
136 if (debug) printf("client count %d\n", g_list_length(rc->clients)); | 132 DEBUG_1("client count %d\n", g_list_length(rc->clients)); |
137 } | 133 } |
138 | 134 |
139 static void remote_server_clients_close(RemoteConnection *rc) | 135 static void remote_server_clients_close(RemoteConnection *rc) |
140 { | 136 { |
141 while (rc->clients) | 137 while (rc->clients) |
254 addr.sun_family = AF_UNIX; | 250 addr.sun_family = AF_UNIX; |
255 sun_path_len = MIN(strlen(path) + 1, UNIX_PATH_MAX); | 251 sun_path_len = MIN(strlen(path) + 1, UNIX_PATH_MAX); |
256 strncpy(addr.sun_path, path, sun_path_len); | 252 strncpy(addr.sun_path, path, sun_path_len); |
257 if (connect(fd, &addr, sizeof(addr)) == -1) | 253 if (connect(fd, &addr, sizeof(addr)) == -1) |
258 { | 254 { |
259 if (debug) printf("error connecting to socket: %s\n", strerror(errno)); | 255 DEBUG_1("error connecting to socket: %s\n", strerror(errno)); |
260 close(fd); | 256 close(fd); |
261 return NULL; | 257 return NULL; |
262 } | 258 } |
263 | 259 |
264 rc = g_new0(RemoteConnection, 1); | 260 rc = g_new0(RemoteConnection, 1); |