Attached is a quick and dirty patch that sends a NOOP if the pipe read
times out after 75% of cosign_net_timeout. This keeps the pusher
connections alive. You still lose the first transaction after a pusher
<-> daemon connection dies but at least an idle connection is held
open.. Patch also adds a syslog message when the server side of the
pusher connection goes away unexpectedly.
comments / corrections welcome.
Paul
On 12/3/2008 3:26 PM, Andrew Mortensen wrote:
On Dec 3, 2008, at 4:05 PM, Paul M Fleming wrote:
... [snip other stuff I'll get to when I have more time] ...
I'm new to the cosign codebase. Is their anyway to determine if the
snet_getline returns as a result of a timeout or is a select required to
do that?
snet_getline uses select internally. In the case of a timeout,
snet_getline sets errno to ETIMEDOUT, which you can check for in the
caller.
andrew
--- pusher.c.orig Wed Dec 3 15:46:10 2008
+++ pusher.c Wed Dec 3 16:20:30 2008
@@ -395,6 +395,7 @@
struct timeval tv;
struct stat st;
struct cinfo ci;
+ char *NOOP = "NOOP";
if (( csn = snet_attach( cpipe, 1024 * 1024 )) == NULL ) {
syslog( LOG_ERR, "pusher: snet_attach: %m" );
@@ -417,9 +418,16 @@
for ( ;; ) {
krb = 0;
- if (( line = snet_getline( csn, NULL )) == NULL ) {
- syslog( LOG_ERR, "pusher: snet_getline: %m" );
- exit( 1 );
+ tv = cosign_net_timeout;
+ tv.tv_sec = (int) cosign_net_timeout.tv_sec * 0.75;
+ if (( line = snet_getline( csn, &tv )) == NULL ) {
+ if (errno == ETIMEDOUT) {
+ line = NOOP;
+ }
+ else {
+ syslog( LOG_ERR, "pusher: snet_getline: %m" );
+ exit( 1 );
+ }
}
if (( ac = argcargv( line, &av )) < 0 ) {
@@ -464,6 +472,13 @@
snet_writef( cur->cl_sn, "LOGOUT %s %s\r\n", av[ 1 ], av[ 2 ] );
break;
+ case 1 :
+ if (( strcasecmp( av[ 0 ], "noop" )) != 0 ) {
+ syslog( LOG_ERR, "pusher: %s: bad command", av[ 0 ] );
+ exit( 1 );
+ }
+ snet_writef( cur->cl_sn, "NOOP\r\n");
+ break;
default :
syslog( LOG_ERR, "pusher: wrong number of args" );
exit( 1 );
@@ -474,6 +489,7 @@
if ( !snet_eof( cur->cl_sn )) {
syslog( LOG_ERR, "pusher: getline: %m" );
}
+ syslog( LOG_ERR, "pusher: server side went away" );
exit( 1 );
}
[EMAIL PROTECTED] daemon]# diff -c pusher.c.orig pusher.c
*** pusher.c.orig Wed Dec 3 15:46:10 2008
--- pusher.c Wed Dec 3 16:20:30 2008
***************
*** 395,400 ****
--- 395,401 ----
struct timeval tv;
struct stat st;
struct cinfo ci;
+ char *NOOP = "NOOP";
if (( csn = snet_attach( cpipe, 1024 * 1024 )) == NULL ) {
syslog( LOG_ERR, "pusher: snet_attach: %m" );
***************
*** 417,425 ****
for ( ;; ) {
krb = 0;
! if (( line = snet_getline( csn, NULL )) == NULL ) {
! syslog( LOG_ERR, "pusher: snet_getline: %m" );
! exit( 1 );
}
if (( ac = argcargv( line, &av )) < 0 ) {
--- 418,433 ----
for ( ;; ) {
krb = 0;
! tv = cosign_net_timeout;
! tv.tv_sec = (int) cosign_net_timeout.tv_sec * 0.75;
! if (( line = snet_getline( csn, &tv )) == NULL ) {
! if (errno == ETIMEDOUT) {
! line = NOOP;
! }
! else {
! syslog( LOG_ERR, "pusher: snet_getline: %m" );
! exit( 1 );
! }
}
if (( ac = argcargv( line, &av )) < 0 ) {
***************
*** 464,469 ****
--- 472,484 ----
snet_writef( cur->cl_sn, "LOGOUT %s %s\r\n", av[ 1 ], av[ 2 ] );
break;
+ case 1 :
+ if (( strcasecmp( av[ 0 ], "noop" )) != 0 ) {
+ syslog( LOG_ERR, "pusher: %s: bad command", av[ 0 ] );
+ exit( 1 );
+ }
+ snet_writef( cur->cl_sn, "NOOP\r\n");
+ break;
default :
syslog( LOG_ERR, "pusher: wrong number of args" );
exit( 1 );
***************
*** 474,479 ****
--- 489,495 ----
if ( !snet_eof( cur->cl_sn )) {
syslog( LOG_ERR, "pusher: getline: %m" );
}
+ syslog( LOG_ERR, "pusher: server side went away" );
exit( 1 );
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Cosign-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cosign-discuss