Lines Matching full:client
40 struct client {
54 struct client **clients;
68 static void client_close(struct client *client)
70 struct socket_handler *sh = client->sh;
73 close(client->fd);
74 if (client->poller) {
75 console_poller_unregister(sh->console, client->poller);
78 if (client->rbc) {
79 ringbuffer_consumer_unregister(client->rbc);
83 if (sh->clients[idx] == client) {
90 free(client);
91 client = NULL;
111 static void client_set_blocked(struct client *client, bool blocked)
115 if (client->blocked == blocked) {
119 client->blocked = blocked;
122 if (client->blocked) {
126 console_poller_set_events(client->sh->console, client->poller, events);
129 static ssize_t send_all(struct client *client, void *buf, size_t len,
141 fd = client->fd;
153 client_set_blocked(client, true);
174 static int client_drain_queue(struct client *client, size_t force_len)
187 if (!block && client->blocked) {
192 len = ringbuffer_dequeue_peek(client->rbc, total_len, &buf);
197 wlen = send_all(client, buf, len, block);
217 ringbuffer_dequeue_commit(client->rbc, total_len);
224 struct client *client = arg;
228 len = ringbuffer_len(client->rbc);
233 console_poller_set_timeout(client->sh->console, client->poller,
238 rc = client_drain_queue(client, force_len);
240 client->rbc = NULL;
241 client_close(client);
251 struct client *client = data;
254 if (client->blocked) {
260 rc = client_drain_queue(client, 0);
262 client->poller = NULL;
263 client_close(client);
274 struct client *client = data;
279 rc = recv(client->fd, buf, sizeof(buf), MSG_DONTWAIT);
294 client_set_blocked(client, false);
295 rc = client_drain_queue(client, 0);
304 client->poller = NULL;
305 client_close(client);
313 struct client *client;
328 client = malloc(sizeof(*client));
329 memset(client, 0, sizeof(*client));
331 client->sh = sh;
332 client->fd = fd;
333 client->poller = console_poller_register(sh->console, handler,
335 client->fd, POLLIN, client);
336 client->rbc = console_ringbuffer_consumer_register(
337 sh->console, client_ringbuffer_poll, client);
348 sh->clients[n] = client;
360 struct client *client;
384 client = malloc(sizeof(*client));
385 if (client == NULL) {
386 warnx("Failed to allocate client structure.");
390 memset(client, 0, sizeof(*client));
392 client->sh = sh;
393 client->fd = fds[0];
394 client->poller = console_poller_register(sh->console, &sh->handler,
396 client->fd, POLLIN, client);
397 client->rbc = console_ringbuffer_consumer_register(
398 sh->console, client_ringbuffer_poll, client);
399 if (client->rbc == NULL) {
415 sh->clients[n] = client;
421 free(client);
508 struct client *c = sh->clients[0];