commit 7363200787962a5c8c757f309e71293dd39a3db9 from: Tracey Emery date: Thu Jul 30 16:35:22 2020 UTC remove unused prototype commit - 8b0186ed01081d1606f79a5b4b5f7a91f0a77a4a commit + 7363200787962a5c8c757f309e71293dd39a3db9 blob - 60f663314972098c99b48d29a5581d8537be4d54 blob + 2192cdbe338a9f1a568a28f49826acc4f6173fa9 --- thingsd/client.c +++ thingsd/client.c @@ -51,10 +51,13 @@ client_conn(int fd, short event, void *arg) if ((client = calloc(1, sizeof(*client))) == NULL) goto err; + if ((client->ev = calloc(1, sizeof(*client->ev))) == NULL) goto err; + if ((sock = get_socket(env, fd)) == NULL) goto err; + if (sock->tls) { if (tls_accept_socket(sock->tls_ctx, &client->tls_ctx, client_fd) == -1) { @@ -333,6 +336,7 @@ client_wr_things(struct client *client, struct thing * if ((pkt = calloc(len, sizeof(*pkt))) == NULL) return; + switch (thing->type) { case TCP: case DEV: @@ -343,6 +347,7 @@ client_wr_things(struct client *client, struct thing * " failed", __func__); return; } + evbuffer_remove(client->evb, pkt, len); write(thing->fd, pkt, len); close(thing->fd); @@ -388,12 +393,14 @@ client_tls_writecb(int fd, short event, void *arg) ret = tls_write(client->tls_ctx, EVBUFFER_DATA(bufev->output), EVBUFFER_LENGTH(bufev->output)); + if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT) { goto retry; } else if (ret < 0) { towrite |= EVBUFFER_ERROR; goto err; } + len = ret; evbuffer_drain(bufev->output, len); } @@ -473,6 +480,7 @@ start_client_chk(struct thingsd *env) rclient_chk = pthread_create(&tclient_chk, NULL, client_chk, (void *)env); + if (rclient_chk) { log_warnx("%s: thread creation failed", __func__); client_chk((void *) env); blob - 1c1b56351fc4705118174ded4de12fc1208b8e91 blob + 61a694204bd6e8867f54b4e916d78849b14ae2e1 --- thingsd/parse.y +++ thingsd/parse.y @@ -93,16 +93,15 @@ static int errors; static struct thing *new_thing; const int baudrates[18] = {50, 75, 110, 134, 150, 200, - 300, 600, 1200, 1800, 2400, 4800, 9600, - 38400, 57600, 76800, 115200}; + 300, 600, 1200, 1800, 2400, 4800, 9600, + 38400, 57600, 76800, 115200}; const char *parity[4] = {"none", "odd", "even", "space"}; struct client *client, *tclient; char my_name[THINGSD_MAXTEXT]; int my_fd, pkt_len; size_t pn; -struct thing *conf_new_thing(char *); -void *conf_del_thing(struct thing *); +struct thing *conf_new_thing(char *); typedef struct { union { blob - 915cfd554603f023034d2accdb8d04e648834dc2 blob + 570213c38e52e6d6d7382356f8f5e0fca9784236 --- thingsd/thingsd.h +++ thingsd/thingsd.h @@ -24,9 +24,9 @@ #define dprintf(x...) #endif /* THINGSD_DEBUG */ -#define THINGSD_CONF "/etc/thingsd.conf" -#define THINGSD_SOCKET "/var/run/thingsd.sock" -#define THINGSD_USER "_thingsd" +#define THINGSD_CONF "/etc/thingsd.conf" +#define THINGSD_SOCKET "/var/run/thingsd.sock" +#define THINGSD_USER "_thingsd" #define CONN_RETRY 30 #define MIN_RETRY 10