summaryrefslogtreecommitdiff
path: root/source3/smbd/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd/process.c')
-rw-r--r--source3/smbd/process.c65
1 files changed, 35 insertions, 30 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 43d3c6c531..007621f6bb 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -42,8 +42,8 @@ extern int last_message;
extern int global_oplock_break;
extern userdom_struct current_user_info;
extern int smb_read_error;
-SIG_ATOMIC_T reload_after_sighup;
-SIG_ATOMIC_T got_sig_term;
+extern VOLATILE sig_atomic_t reload_after_sighup;
+extern VOLATILE sig_atomic_t got_sig_term;
extern BOOL global_machine_password_needs_changing;
extern fstring global_myworkgroup;
extern pstring global_myname;
@@ -109,12 +109,10 @@ BOOL push_oplock_pending_smb_message(char *buf, int msg_len)
oplock messages, change notify events etc.
****************************************************************************/
-static void async_processing(char *buffer, int buffer_len)
+static void async_processing(fd_set *fds, char *buffer, int buffer_len)
{
- DEBUG(10,("async_processing: Doing async processing.\n"));
-
/* check for oplock messages (both UDP and kernel) */
- if (receive_local_message(buffer, buffer_len, 1)) {
+ if (receive_local_message(fds, buffer, buffer_len, 0)) {
process_local_message(buffer, buffer_len);
}
@@ -195,27 +193,6 @@ static BOOL receive_message_or_smb(char *buffer, int buffer_len, int timeout)
*/
FD_ZERO(&fds);
-
- /*
- * Ensure we process oplock break messages by preference.
- * We have to do this before the select, after the select
- * and if the select returns EINTR. This is due to the fact
- * that the selects called from async_processing can eat an EINTR
- * caused by a signal (we can't take the break message there).
- * This is hideously complex - *MUST* be simplified for 3.0 ! JRA.
- */
-
- if (oplock_message_waiting(&fds)) {
- DEBUG(10,("receive_message_or_smb: oplock_message is waiting.\n"));
- async_processing(buffer, buffer_len);
- /*
- * After async processing we must go and do the select again, as
- * the state of the flag in fds for the server file descriptor is
- * indeterminate - we may have done I/O on it in the oplock processing. JRA.
- */
- goto again;
- }
-
FD_SET(smbd_server_fd(),&fds);
maxfd = setup_oplock_select_set(&fds);
@@ -229,7 +206,7 @@ static BOOL receive_message_or_smb(char *buffer, int buffer_len, int timeout)
is the best we can do until the oplock code knows more about
signals */
if (selrtn == -1 && errno == EINTR) {
- async_processing(buffer, buffer_len);
+ async_processing(&fds, buffer, buffer_len);
/*
* After async processing we must go and do the select again, as
* the state of the flag in fds for the server file descriptor is
@@ -258,7 +235,7 @@ static BOOL receive_message_or_smb(char *buffer, int buffer_len, int timeout)
*/
if (oplock_message_waiting(&fds)) {
- async_processing(buffer, buffer_len);
+ async_processing(&fds, buffer, buffer_len);
/*
* After async processing we must go and do the select again, as
* the state of the flag in fds for the server file descriptor is
@@ -298,6 +275,7 @@ BOOL receive_next_smb(char *inbuf, int bufsize, int timeout)
void respond_to_all_remaining_local_messages(void)
{
char buffer[1024];
+ fd_set fds;
/*
* Assert we have no exclusive open oplocks.
@@ -310,12 +288,23 @@ void respond_to_all_remaining_local_messages(void)
}
/*
+ * Setup the select read fd set.
+ */
+
+ FD_ZERO(&fds);
+ if(!setup_oplock_select_set(&fds))
+ return;
+
+ /*
* Keep doing receive_local_message with a 1 ms timeout until
* we have no more messages.
*/
- while(receive_local_message(buffer, sizeof(buffer), 1)) {
+ while(receive_local_message(&fds, buffer, sizeof(buffer), 1)) {
/* Deal with oplock break requests from other smbd's. */
process_local_message(buffer, sizeof(buffer));
+
+ FD_ZERO(&fds);
+ (void)setup_oplock_select_set(&fds);
}
return;
@@ -840,6 +829,10 @@ set. Ignoring max smbd restriction.\n"));
****************************************************************************/
void process_smb(char *inbuf, char *outbuf)
{
+#ifdef WITH_SSL
+ extern BOOL sslEnabled; /* don't use function for performance reasons */
+ static int sslConnected = 0;
+#endif /* WITH_SSL */
static int trans_num;
int msg_type = CVAL(inbuf,0);
int32 len = smb_len(inbuf);
@@ -867,6 +860,18 @@ void process_smb(char *inbuf, char *outbuf)
DEBUG( 6, ( "got message type 0x%x of len 0x%x\n", msg_type, len ) );
DEBUG( 3, ( "Transaction %d of length %d\n", trans_num, nread ) );
+#ifdef WITH_SSL
+ if(sslEnabled && !sslConnected){
+ sslConnected = sslutil_negotiate_ssl(smbd_server_fd(), msg_type);
+ if(sslConnected < 0){ /* an error occured */
+ exit_server("SSL negotiation failed");
+ }else if(sslConnected){
+ trans_num++;
+ return;
+ }
+ }
+#endif /* WITH_SSL */
+
if (msg_type == 0)
show_msg(inbuf);
else if(msg_type == SMBkeepalive)