diff options
author | Andrew Tridgell <tridge@samba.org> | 1996-06-10 05:16:19 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1996-06-10 05:16:19 +0000 |
commit | a521fe8a274c8a043cf77641dd4160fdef803533 (patch) | |
tree | 67bbb5bb827896e10f7e611d02a8e5710a9045fe /source3/smbd/server.c | |
parent | 7e3b4a1c0df1434eb3d02f93c736ce065f9898d8 (diff) | |
download | samba-a521fe8a274c8a043cf77641dd4160fdef803533.tar.gz samba-a521fe8a274c8a043cf77641dd4160fdef803533.tar.bz2 samba-a521fe8a274c8a043cf77641dd4160fdef803533.zip |
a cleanup of the receive_smb() usage, adding timeouts in some places
also added paranoid code in the main process() loop of smbd to detect
when smbd is looping uselessly. This should stop the "smbd is chewing
lots of cpu" reports
(This used to be commit 8e9dce34d50d673cb50531f0c4c7672ce2522cef)
Diffstat (limited to 'source3/smbd/server.c')
-rw-r--r-- | source3/smbd/server.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/source3/smbd/server.c b/source3/smbd/server.c index ecc8e4ce9c..3ececed393 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -3445,6 +3445,27 @@ static void process(void) t = time(NULL); + { + /* the following bit of code was added to combat smbd + looping chewing lots of CPU time. It should never + actually be needed, but it seems that some systems + don't set error correctly, which is used to distinguish + a select() timeout from a read error + + we exit if receive_smb() returns false 3 times in one second. + */ + static int error_count=0; + static time_t error_time=0; + if (error_count==0) { + error_time = t; + } else if (error_time != t) { + error_count = 0; + } else if (error_count++ > 2) { + exit_server("looping in process()\n"); + } + } + + /* become root again if waiting */ unbecome_user(); |