svn commit: samba r13482 - in branches/SAMBA_3_0/source: include
smbd
jpeach at samba.org
jpeach at samba.org
Mon Feb 13 04:07:16 GMT 2006
Author: jpeach
Date: 2006-02-13 04:07:15 +0000 (Mon, 13 Feb 2006)
New Revision: 13482
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=13482
Log:
Push the FAM notification file descriptor into the select
set to avoid unnecessary polling.
Modified:
branches/SAMBA_3_0/source/include/smb.h
branches/SAMBA_3_0/source/smbd/notify.c
branches/SAMBA_3_0/source/smbd/notify_fam.c
branches/SAMBA_3_0/source/smbd/notify_hash.c
branches/SAMBA_3_0/source/smbd/notify_kernel.c
branches/SAMBA_3_0/source/smbd/oplock.c
branches/SAMBA_3_0/source/smbd/process.c
Changeset:
Modified: branches/SAMBA_3_0/source/include/smb.h
===================================================================
--- branches/SAMBA_3_0/source/include/smb.h 2006-02-13 00:08:16 UTC (rev 13481)
+++ branches/SAMBA_3_0/source/include/smb.h 2006-02-13 04:07:15 UTC (rev 13482)
@@ -1581,6 +1581,7 @@
BOOL (*check_notify)(connection_struct *conn, uint16 vuid, char *path, uint32 flags, void *data, time_t t);
void (*remove_notify)(void *data);
int select_time;
+ int notification_fd;
};
#include "smb_macros.h"
Modified: branches/SAMBA_3_0/source/smbd/notify.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/notify.c 2006-02-13 00:08:16 UTC (rev 13481)
+++ branches/SAMBA_3_0/source/smbd/notify.c 2006-02-13 04:07:15 UTC (rev 13482)
@@ -206,6 +206,15 @@
return True;
}
+int change_notify_fd(void)
+{
+ if (cnotify) {
+ return cnotify->notification_fd;
+ }
+
+ return -1;
+}
+
/****************************************************************************
Initialise the change notify subsystem.
****************************************************************************/
Modified: branches/SAMBA_3_0/source/smbd/notify_fam.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/notify_fam.c 2006-02-13 00:08:16 UTC (rev 13481)
+++ branches/SAMBA_3_0/source/smbd/notify_fam.c 2006-02-13 04:07:15 UTC (rev 13482)
@@ -63,9 +63,30 @@
#define FAM_TRACE 8
#define FAM_TRACE_LOW 10
-#define FAM_NOTIFY_CHECK_TIMEOUT 1 /* secs */
#define FAM_EVENT_DRAIN ((uint32_t)(-1))
+static void * fam_register_notify(connection_struct * conn,
+ char * path,
+ uint32 flags);
+
+static BOOL fam_check_notify(connection_struct * conn,
+ uint16_t vuid,
+ char * path,
+ uint32_t flags,
+ void * data,
+ time_t when);
+
+static void fam_remove_notify(void * data)
+
+static struct cnotify_fns global_fam_notify =
+{
+ fam_register_notify,
+ fam_check_notify,
+ fam_remove_notify,
+ -1,
+ -1
+};
+
/* Turn a FAM event code into a string. Don't rely on specific code values,
* because that might not work across all flavours of FAM.
*/
@@ -110,6 +131,7 @@
}
}
+ global_fam_notify.notification_fd = FAMCONNECTION_GETFD(&global_fc);
return(True);
}
@@ -420,18 +442,6 @@
struct cnotify_fns * fam_notify_init(void)
{
- static struct cnotify_fns global_fam_notify =
- {
- fam_register_notify,
- fam_check_notify,
- fam_remove_notify,
- FAM_NOTIFY_CHECK_TIMEOUT
- };
-
- /* TODO: rather than relying on FAM_NOTIFY_CHECK_TIMEOUT, we should have an
- * API to push the FAM fd into the global server fd set.
- */
-
FAMCONNECTION_GETFD(&global_fc) = -1;
if (!fam_test_connection()) {
Modified: branches/SAMBA_3_0/source/smbd/notify_hash.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/notify_hash.c 2006-02-13 00:08:16 UTC (rev 13481)
+++ branches/SAMBA_3_0/source/smbd/notify_hash.c 2006-02-13 04:07:15 UTC (rev 13482)
@@ -230,6 +230,7 @@
cnotify.check_notify = hash_check_notify;
cnotify.remove_notify = hash_remove_notify;
cnotify.select_time = lp_change_notify_timeout();
+ cnotify.notification_fd = -1;
return &cnotify;
}
Modified: branches/SAMBA_3_0/source/smbd/notify_kernel.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/notify_kernel.c 2006-02-13 00:08:16 UTC (rev 13481)
+++ branches/SAMBA_3_0/source/smbd/notify_kernel.c 2006-02-13 04:07:15 UTC (rev 13482)
@@ -232,6 +232,7 @@
cnotify.check_notify = kernel_check_notify;
cnotify.remove_notify = kernel_remove_notify;
cnotify.select_time = -1;
+ cnotify.notification_fd = -1;
/* the signal can start off blocked due to a bug in bash */
BlockSignals(False, RT_SIGNAL_NOTIFY);
Modified: branches/SAMBA_3_0/source/smbd/oplock.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/oplock.c 2006-02-13 00:08:16 UTC (rev 13481)
+++ branches/SAMBA_3_0/source/smbd/oplock.c 2006-02-13 04:07:15 UTC (rev 13482)
@@ -240,21 +240,16 @@
}
/****************************************************************************
- Setup the listening set of file descriptors for an oplock break
- message either from the UDP socket or from the kernel. Returns the maximum
- fd used.
+ Return the fd (if any) used for receiving oplock notifications.
****************************************************************************/
-int setup_oplock_select_set( fd_set *fds)
+int oplock_notify_fd(void)
{
- int maxfd = 0;
-
- if (koplocks && koplocks->notification_fd != -1) {
- FD_SET(koplocks->notification_fd, fds);
- maxfd = MAX(maxfd, koplocks->notification_fd);
+ if (koplocks) {
+ return koplocks->notification_fd;
}
- return maxfd;
+ return -1;
}
/****************************************************************************
Modified: branches/SAMBA_3_0/source/smbd/process.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/process.c 2006-02-13 00:08:16 UTC (rev 13481)
+++ branches/SAMBA_3_0/source/smbd/process.c 2006-02-13 04:07:15 UTC (rev 13482)
@@ -283,7 +283,7 @@
return result;
}
-
+
/****************************************************************************
Do all async processing in here. This includes kernel oplock messages, change
notify events etc.
@@ -319,6 +319,20 @@
}
/****************************************************************************
+ Add a fd to the set we will be select(2)ing on.
+****************************************************************************/
+
+static int select_on_fd(int fd, int maxfd, fd_set *fds)
+{
+ if (fd != -1) {
+ FD_SET(fd, fds);
+ maxfd = MAX(maxfd, fd);
+ }
+
+ return maxfd;
+}
+
+/****************************************************************************
Do a select on an two fd's - with timeout.
If a local udp message has been pushed onto the
@@ -344,7 +358,7 @@
fd_set fds;
int selrtn;
struct timeval to = timeval_set(SMBD_SELECT_TIMEOUT, 0);
- int maxfd;
+ int maxfd = 0;
smb_read_error = 0;
@@ -437,10 +451,11 @@
}
}
- FD_SET(smbd_server_fd(),&fds);
- maxfd = setup_oplock_select_set(&fds);
+ maxfd = select_on_fd(smbd_server_fd(), maxfd, &fds);
+ maxfd = select_on_fd(change_notify_fd(), maxfd, &fds);
+ maxfd = select_on_fd(oplock_notify_fd(), maxfd, &fds);
- selrtn = sys_select(MAX(maxfd,smbd_server_fd())+1,&fds,NULL,NULL,&to);
+ selrtn = sys_select(maxfd+1,&fds,NULL,NULL,&to);
/* if we get EINTR then maybe we have received an oplock
signal - treat this as select returning 1. This is ugly, but
More information about the samba-cvs
mailing list