synk

synchronize files between hosts
Log | Files | Refs | README | LICENSE

commit cc46dfd595f112a68c17b7d01be792228e506aec
parent 06e9c0735e637b1caf7bc32415880039e303f488
Author: Willy <willyatmailoodotorg>
Date:   Sat Sep  3 23:34:46 +0200

Use SIGALRM to make the server timeout

Diffstat:
synk.c | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/synk.c b/synk.c @@ -24,6 +24,7 @@ #define TIMESTAMP_MAX 19 /* length of LONG_MAX */ #define CONNECTION_MAX 1 #define RECVSIZ 512 +#define TIMEOUT 5 /* hold a socket connection, used to pass a connection to a thread */ struct client_t { @@ -287,6 +288,8 @@ serverloop(in_addr_t host, in_port_t port) return -1; } + alarm(0); /* cancel previously set SIGALRM */ + c = malloc(sizeof(struct client_t)); c->fd = cfd; c->inet = clt.sin_addr; @@ -566,6 +569,7 @@ main(int argc, char *argv[]) } break; case SYNK_SERVER: + alarm(TIMEOUT); serverloop(resolve(hostname)->s_addr, port); break; }