summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-06-12 15:53:31 +0000
committerAndrew Tridgell <tridge@samba.org>2000-06-12 15:53:31 +0000
commitb2d01bd2dbfed8b35cc324fad42eac562fcad3b4 (patch)
tree6d2708c53b61bbd441d7c4a65945b65d543b2f73 /source3/lib
parent6de513cef43ad83ecd1823bde5a4e05c22224b0f (diff)
downloadsamba-b2d01bd2dbfed8b35cc324fad42eac562fcad3b4.tar.gz
samba-b2d01bd2dbfed8b35cc324fad42eac562fcad3b4.tar.bz2
samba-b2d01bd2dbfed8b35cc324fad42eac562fcad3b4.zip
totally rewrote the async signal, notification and oplock notification
handling in Samba. This was needed due to several limitations and races in the previous code - as a side effect the new code is much cleaner :) in summary: - changed sys_select() to avoid a signal/select race condition. It is a rare race but once we have signals doing notification and oplocks it is important. - changed our main processing loop to take advantage of the new sys_select semantics - split the notify code into implementaion dependent and general parts. Added the following structure that defines an implementation: struct cnotify_fns { void * (*register_notify)(connection_struct *conn, char *path, uint32 flags); BOOL (*check_notify)(connection_struct *conn, uint16 vuid, char *path, uint32 flags, void *data, time_t t); void (*remove_notify)(void *data); }; then I wrote two implementations, one using hash/poll (like our old code) and the other using the new Linux kernel change notify. It should be easy to add other change notify implementations by creating a sructure of the above type. - fixed a bug in change notify where we were returning the wrong error code. - rewrote the core change notify code to be much simpler - moved to real-time signals for leases and change notify Amazingly, it all seems to work. I was very surprised! (This used to be commit 44766c39e0027c762bee8b33b12c621c109a3267)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/debug.c4
-rw-r--r--source3/lib/system.c109
2 files changed, 4 insertions, 109 deletions
diff --git a/source3/lib/debug.c b/source3/lib/debug.c
index 675c2d8cfc..a388956d42 100644
--- a/source3/lib/debug.c
+++ b/source3/lib/debug.c
@@ -132,6 +132,8 @@ void sig_usr2( int sig )
DEBUG( 0, ( "Got SIGUSR2; set debug level to %d.\n", DEBUGLEVEL ) );
+ sys_select_signal();
+
#if !defined(HAVE_SIGACTION)
CatchSignal( SIGUSR2, SIGNAL_CAST sig_usr2 );
#endif
@@ -154,6 +156,8 @@ void sig_usr1( int sig )
DEBUG( 0, ( "Got SIGUSR1; set debug level to %d.\n", DEBUGLEVEL ) );
+ sys_select_signal();
+
#if !defined(HAVE_SIGACTION)
CatchSignal( SIGUSR1, SIGNAL_CAST sig_usr1 );
#endif
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 46b01b747a..479bce1965 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -39,115 +39,6 @@ extern int DEBUGLEVEL;
*/
-/*******************************************************************
-this replaces the normal select() system call
-return if some data has arrived on one of the file descriptors
-return -1 means error
-********************************************************************/
-#ifndef HAVE_SELECT
-static int pollfd(int fd)
-{
- int r=0;
-
-#ifdef HAS_RDCHK
- r = rdchk(fd);
-#elif defined(TCRDCHK)
- (void)ioctl(fd, TCRDCHK, &r);
-#else
- (void)ioctl(fd, FIONREAD, &r);
-#endif
-
- return(r);
-}
-
-int sys_select(int maxfd, fd_set *fds,struct timeval *tval)
-{
- fd_set fds2;
- int counter=0;
- int found=0;
-
- FD_ZERO(&fds2);
-
- while (1)
- {
- int i;
- for (i=0;i<maxfd;i++) {
- if (FD_ISSET(i,fds) && pollfd(i)>0) {
- found++;
- FD_SET(i,&fds2);
- }
- }
-
- if (found) {
- memcpy((void *)fds,(void *)&fds2,sizeof(fds2));
- return(found);
- }
-
- if (tval && tval->tv_sec < counter) return(0);
- sleep(1);
- counter++;
- }
-}
-
-#else /* !NO_SELECT */
-int sys_select(int maxfd, fd_set *fds,struct timeval *tval)
-{
-#ifdef USE_POLL
- struct pollfd pfd[256];
- int i;
- int maxpoll;
- int timeout;
- int pollrtn;
-
- maxpoll = 0;
- for( i = 0; i < maxfd; i++) {
- if(FD_ISSET(i,fds)) {
- struct pollfd *pfdp = &pfd[maxpoll++];
- pfdp->fd = i;
- pfdp->events = POLLIN;
- pfdp->revents = 0;
- }
- }
-
- timeout = (tval != NULL) ? (tval->tv_sec * 1000) + (tval->tv_usec/1000) :
- -1;
- errno = 0;
- pollrtn = poll( &pfd[0], maxpoll, timeout);
-
- FD_ZERO(fds);
-
- for( i = 0; i < maxpoll; i++)
- if( pfd[i].revents & POLLIN )
- FD_SET(pfd[i].fd,fds);
-
- return pollrtn;
-#else /* USE_POLL */
-
- struct timeval t2;
- int selrtn;
-
- if (tval) memcpy((void *)&t2,(void *)tval,sizeof(t2));
- errno = 0;
- selrtn = select(maxfd,SELECT_CAST fds,NULL,NULL,tval?&t2:NULL);
-
- return(selrtn);
-}
-#endif /* USE_POLL */
-#endif /* NO_SELECT */
-
-/*******************************************************************
-similar to sys_select() but catch EINTR and continue
-this is what sys_select() used to do in Samba
-********************************************************************/
-int sys_select_intr(int maxfd, fd_set *fds,struct timeval *tval)
-{
- int ret;
- do {
- ret = sys_select(maxfd, fds, tval);
- } while (ret == -1 && errno == EINTR);
- return ret;
-}
-
/*******************************************************************
A wrapper for usleep in case we don't have one.