X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Futils%2Funixsock.c;fp=src%2Futils%2Funixsock.c;h=da992c94b51601024bc03e2988ca9ff8d7a1e9d8;hb=012b412eb5165f331dc378e9b6d00517b8003e0b;hp=59bf5631f451e4f401883532e8cd9b1dc4c8791d;hpb=09f52d643f0c07cc0e0db33d7a5f72782390fc5a;p=sysdb.git diff --git a/src/utils/unixsock.c b/src/utils/unixsock.c index 59bf563..da992c9 100644 --- a/src/utils/unixsock.c +++ b/src/utils/unixsock.c @@ -292,21 +292,30 @@ char * sdb_unixsock_client_recv(sdb_unixsock_client_t *client, char *buffer, size_t buflen) { + char *tmp; + if ((! client) || (! client->fh) || (! buffer)) return NULL; if (client->shutdown & SDB_SHUT_RD) /* reconnect */ sdb_unixsock_client_connect(client); - buffer = fgets(buffer, (int)buflen - 1, client->fh); - if (! buffer) { - if (! feof(client->fh)) { - char errbuf[1024]; - sdb_log(SDB_LOG_ERR, "unixsock: Failed to read " - "from socket (%s): %s", client->path, - sdb_strerror(errno, errbuf, sizeof(errbuf))); + tmp = NULL; + while (tmp == NULL) { + errno = 0; + tmp = fgets(buffer, (int)buflen - 1, client->fh); + if (! tmp) { + if ((errno == EAGAIN) || (errno == EINTR)) + continue; + + if (! feof(client->fh)) { + char errbuf[1024]; + sdb_log(SDB_LOG_ERR, "unixsock: Failed to read " + "from socket (%s): %s", client->path, + sdb_strerror(errno, errbuf, sizeof(errbuf))); + } + return NULL; } - return buffer; } buffer[buflen - 1] = '\0';