commit: r456 - trunk/daemon
[email protected] Tue, 10 Jan 2012 12:40:41 -0500
| Newsgroups | gmane.network.spread.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: jschultz Date: 2012-01-10 12:40:40 -0500 (Tue, 10 Jan 2012) New Revision: 456 Modified: trunk/daemon/Changelog trunk/daemon/session.c Log: Changed the way we badger sessions to now also monitor for writeability with LOW_PRIORITY. Modified: trunk/daemon/Changelog =================================================================== --- trunk/daemon/Changelog 2012-01-09 20:35:02 UTC (rev 455) +++ trunk/daemon/Changelog 2012-01-10 17:40:40 UTC (rev 456) @@ -1,3 +1,17 @@ +Tue Jan 10 12:30:48 2012 John Schultz <[email protected]> + + * session.c: Changed the way we "badger" client sessions that have + blocked. We now schedule both timeout and write-ability callbacks + on the client session. This should ensure that clients usuaully + don't see long delays in the delivery of their messages due to the + badger timeout. That old behavior can reassert itself during + memberships where we block LOW_PRIORITY events. It was felt that + condition is so rare and we will likely block delivery of messages + right around the membership regardless (until EVS closes) as to + be a minimal concern versus treating writeable clients as + MEDIUM or HIGH priority events, which could have unforseen negative + effects on Spread's event processing. + Mon Jan 9 12:52:10 2012 John Schultz <[email protected]> * sp.c, session.c: Added SO_KEEPALIVE to client sessions. Modified: trunk/daemon/session.c =================================================================== --- trunk/daemon/session.c 2012-01-09 20:35:02 UTC (rev 455) +++ trunk/daemon/session.c 2012-01-10 17:40:40 UTC (rev 456) @@ -110,7 +110,9 @@ static void Sess_accept( mailbox mbox, int domain, void *dummy ); static void Sess_accept_continue( mailbox, int, void * ); static void Sess_read( mailbox mbox, int domain, void *dummy ); -static void Sess_badger( mailbox mbox, void *dummy ); +static void Sess_badger( mailbox mbox ); +static void Sess_badger_TO( mailbox mbox, void *dummy ); +static void Sess_badger_FD( mailbox mbox, int dmy, void *dmy2 ); static void Sess_kill( mailbox mbox ); static void Sess_handle_join( message_link *mess_link ); static void Sess_handle_leave( message_link *mess_link ); @@ -1456,9 +1458,10 @@ } /* close the mailbox and mark it unoperational */ - E_dequeue( Sess_badger, mbox, NULL ); + E_dequeue( Sess_badger_TO, mbox, NULL ); E_detach_fd( mbox, READ_FD ); E_detach_fd( mbox, EXCEPT_FD ); + E_detach_fd( mbox, WRITE_FD ); close( mbox ); /* the mailbox is closed but the entry still points to it */ Sessions[ses].status = Clear_op_session( Sessions[ses].status ); @@ -1552,7 +1555,7 @@ if( Sessions[ses].num_mess > 0 ) { - Sess_badger( Sessions[ses].mbox , NULL); + Sess_badger( Sessions[ses].mbox ); } msg = mess_link->mess; @@ -1656,7 +1659,8 @@ Message_calculate_current_location(tmp_link->mess, len_sent, &(Sessions[ses].write) ); /* We will need to badger this guy */ - E_queue( Sess_badger, Sessions[ses].mbox, NULL, Badger_timeout ); + E_queue( Sess_badger_TO, Sessions[ses].mbox, NULL, Badger_timeout ); + E_attach_fd( Sessions[ses].mbox, WRITE_FD, Sess_badger_FD, 0, NULL, LOW_PRIORITY ); }else{ /* This guy was already badgered */ Sessions[ses].last->next = tmp_link; @@ -1667,7 +1671,7 @@ Message_Dec_Refcount(msg); } -static void Sess_badger( mailbox mbox, void *dummy ) +static void Sess_badger( mailbox mbox ) { int ses; message_link *mess_link; @@ -1681,11 +1685,8 @@ Alarm( SESSION, "Sess_badger: for mbox %d\n", mbox ); ses = Sess_get_session_index( mbox ); - if( ses < 0 || ses >= MAX_SESSIONS ) return; - if( !Is_op_session( Sessions[ses].status ) ) return; + if( ses < 0 || ses >= MAX_SESSIONS || !Is_op_session( Sessions[ses].status ) || Sessions[ses].num_mess <= 0 ) goto NO_WORK; - if( Sessions[ses].num_mess <= 0 ) return; - /* set file descriptor to non blocking */ ioctl_cmd = 1; ret = ioctl( mbox, FIONBIO, &ioctl_cmd); @@ -1751,9 +1752,27 @@ ioctl_cmd = 0; ret = ioctl( mbox, FIONBIO, &ioctl_cmd); - if( Sessions[ses].num_mess > 0 ) E_queue( Sess_badger, mbox, NULL, Badger_timeout ); + if( Sessions[ses].num_mess > 0 ) { + E_queue( Sess_badger_TO, mbox, NULL, Badger_timeout ); + E_attach_fd( mbox, WRITE_FD, Sess_badger_FD, 0, NULL, LOW_PRIORITY ); + + }else{ + NO_WORK: + E_dequeue( Sess_badger_TO, mbox, NULL ); + E_detach_fd( mbox, WRITE_FD ); + } } +static void Sess_badger_TO( mailbox mbox, void *dmy ) +{ + Sess_badger( mbox ); +} + +static void Sess_badger_FD( mailbox mbox, int dmy, void *dmy2 ) +{ + Sess_badger( mbox ); +} + static void Sess_kill( mailbox mbox ) { int ses; @@ -1813,9 +1832,10 @@ Sessions[ses].read_mess = NULL; /* close the mailbox and mark it unoperational */ - E_dequeue( Sess_badger, mbox, NULL ); + E_dequeue( Sess_badger_TO, mbox, NULL ); E_detach_fd( mbox, READ_FD ); E_detach_fd( mbox, EXCEPT_FD ); + E_detach_fd( mbox, WRITE_FD ); close(mbox); /* the mailbox is closed but the entry still points to it */ Sessions[ses].status = Clear_op_session( Sessions[ses].status );