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.c111
1 files changed, 98 insertions, 13 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index c4c1debbf3..94d4b8d903 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -28,8 +28,7 @@ extern int smb_echo_count;
struct timeval smb_last_time;
static char *InBuffer = NULL;
-char *OutBuffer = NULL;
-char *last_inbuf = NULL;
+static char *OutBuffer = NULL;
/*
* Size of data we can send to client. Set
@@ -287,11 +286,17 @@ static void async_processing(char *buffer, int buffer_len)
{
DEBUG(10,("async_processing: Doing async processing.\n"));
+ process_aio_queue();
+
/* check for oplock messages (both UDP and kernel) */
if (receive_local_message(buffer, buffer_len, 1)) {
process_local_message(buffer, buffer_len);
}
+ /* Do the aio check again after receive_local_message as it does a select
+ and may have eaten our signal. */
+ process_aio_queue();
+
if (got_sig_term) {
exit_server("Caught TERM signal");
}
@@ -981,8 +986,6 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize
!check_access(smbd_server_fd(), lp_hostsallow(-1), lp_hostsdeny(-1))))
return(ERROR_DOS(ERRSRV,ERRaccess));
- last_inbuf = inbuf;
-
outsize = smb_messages[type].fn(conn, inbuf,outbuf,size,bufsize);
}
@@ -1511,24 +1514,106 @@ machine %s in domain %s.\n", global_myname(), lp_workgroup()));
}
/****************************************************************************
- process commands from the client
+ Accessor functions for InBuffer, OutBuffer.
****************************************************************************/
-void smbd_process(void)
+char *get_InBuffer(void)
{
- time_t last_timeout_processing_time = time(NULL);
- unsigned int num_smbs = 0;
- const size_t total_buffer_size = BUFFER_SIZE + LARGE_WRITEX_HDR_SIZE + SAFETY_MARGIN;
+ return InBuffer;
+}
- InBuffer = (char *)SMB_MALLOC(total_buffer_size);
- OutBuffer = (char *)SMB_MALLOC(total_buffer_size);
- if ((InBuffer == NULL) || (OutBuffer == NULL))
- return;
+void set_InBuffer(char *new_inbuf)
+{
+ InBuffer = new_inbuf;
+}
+
+char *get_OutBuffer(void)
+{
+ return OutBuffer;
+}
+
+void set_OutBuffer(char *new_outbuf)
+{
+ OutBuffer = new_outbuf;
+}
+
+/****************************************************************************
+ Free an InBuffer. Checks if not in use by aio system.
+ Must have been allocated by NewInBuffer.
+****************************************************************************/
+
+void free_InBuffer(char *inbuf)
+{
+ if (!aio_inbuffer_in_use(inbuf)) {
+ SAFE_FREE(inbuf);
+ }
+}
+
+/****************************************************************************
+ Free an OutBuffer. No outbuffers currently stolen by aio system.
+ Must have been allocated by NewInBuffer.
+****************************************************************************/
+
+void free_OutBuffer(char *outbuf)
+{
+ SAFE_FREE(outbuf);
+}
+
+const int total_buffer_size = (BUFFER_SIZE + LARGE_WRITEX_HDR_SIZE + SAFETY_MARGIN);
+/****************************************************************************
+ Allocate a new InBuffer. Returns the new and old ones.
+****************************************************************************/
+
+char *NewInBuffer(char **old_inbuf)
+{
+ char *new_inbuf = (char *)SMB_MALLOC(total_buffer_size);
+ if (!new_inbuf) {
+ return NULL;
+ }
+ if (old_inbuf) {
+ *old_inbuf = InBuffer;
+ }
+ InBuffer = new_inbuf;
#if defined(DEVELOPER)
clobber_region(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, InBuffer, total_buffer_size);
+#endif
+ return InBuffer;
+}
+
+/****************************************************************************
+ Allocate a new OutBuffer. Returns the new and old ones.
+****************************************************************************/
+
+char *NewOutBuffer(char **old_outbuf)
+{
+ char *new_outbuf = (char *)SMB_MALLOC(total_buffer_size);
+ if (!new_outbuf) {
+ return NULL;
+ }
+ if (old_outbuf) {
+ *old_outbuf = OutBuffer;
+ }
+ OutBuffer = new_outbuf;
+#if defined(DEVELOPER)
clobber_region(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, OutBuffer, total_buffer_size);
#endif
+ return OutBuffer;
+}
+
+/****************************************************************************
+ Process commands from the client
+****************************************************************************/
+
+void smbd_process(void)
+{
+ time_t last_timeout_processing_time = time(NULL);
+ unsigned int num_smbs = 0;
+
+ /* Allocate the primary Inbut/Output buffers. */
+
+ if ((NewInBuffer(NULL) == NULL) || (NewOutBuffer(NULL) == NULL))
+ return;
max_recv = MIN(lp_maxxmit(),BUFFER_SIZE);