projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3e11c18
)
make the server connection to citserver nonblocking so we can react with timeouts.
author
Wilfried Goesgens
<dothebart@citadel.org>
Mon, 18 Feb 2013 22:54:54 +0000
(23:54 +0100)
committer
Wilfried Goesgens
<dothebart@citadel.org>
Mon, 18 Feb 2013 22:54:54 +0000
(23:54 +0100)
webcit/tcp_sockets.c
patch
|
blob
|
history
diff --git
a/webcit/tcp_sockets.c
b/webcit/tcp_sockets.c
index b27f2ad864c1c5cd9da9f235e5b6e19de8ab95ec..b5f8adac7e20d5f311eb12b7eb57cb57af3cfa1c 100644
(file)
--- a/
webcit/tcp_sockets.c
+++ b/
webcit/tcp_sockets.c
@@
-36,6
+36,7
@@
RETSIGTYPE timeout(int signum)
int uds_connectsock(char *sockpath)
{
struct sockaddr_un addr;
int uds_connectsock(char *sockpath)
{
struct sockaddr_un addr;
+ int fdflags;
int s;
memset(&addr, 0, sizeof(addr));
int s;
memset(&addr, 0, sizeof(addr));
@@
-54,6
+55,25
@@
int uds_connectsock(char *sockpath)
return(-1);
}
return(-1);
}
+ fdflags = fcntl(s, F_GETFL);
+ if (fdflags < 0) {
+ syslog(LOG_ERR,
+ "unable to get socket %d flags! %s \n",
+ s,
+ strerror(errno));
+ close(s);
+ return -1;
+ }
+ fdflags = fdflags | O_NONBLOCK;
+ if (fcntl(s, F_SETFL, fdflags) < 0) {
+ syslog(LOG_ERR,
+ "unable to set socket %d nonblocking flags! %s \n",
+ s,
+ strerror(errno));
+ close(s);
+ return -1;
+ }
+
return s;
}
return s;
}
@@
-123,7
+143,28
@@
int tcp_connectsock(char *host, char *service)
}
rc = connect(s, ai->ai_addr, ai->ai_addrlen);
if (rc >= 0) {
}
rc = connect(s, ai->ai_addr, ai->ai_addrlen);
if (rc >= 0) {
+ int fdflags;
freeaddrinfo(res);
freeaddrinfo(res);
+
+ fdflags = fcntl(rc, F_GETFL);
+ if (fdflags < 0) {
+ syslog(LOG_ERR,
+ "unable to get socket %d flags! %s \n",
+ rc,
+ strerror(errno));
+ close(rc);
+ return -1;
+ }
+ fdflags = fdflags | O_NONBLOCK;
+ if (fcntl(rc, F_SETFL, fdflags) < 0) {
+ syslog(LOG_ERR,
+ "unable to set socket %d nonblocking flags! %s \n",
+ rc,
+ strerror(errno));
+ close(s);
+ return -1;
+ }
+
return(s);
}
else {
return(s);
}
else {
@@
-153,7
+194,7
@@
int serv_getln(char *strbuf, int bufsize)
FlushStrBuf(WCC->MigrateReadLineBuf);
strbuf[len] = '\0';
#ifdef SERV_TRACE
FlushStrBuf(WCC->MigrateReadLineBuf);
strbuf[len] = '\0';
#ifdef SERV_TRACE
- syslog(LOG_DEBUG, "%3d<<<%s\n", WC->serv_sock, strbuf);
+ syslog(LOG_DEBUG, "%3d<<<%s\n", WC
C
->serv_sock, strbuf);
#endif
return len;
}
#endif
return len;
}