Re: [SCM] Samba Shared Repository - branch master updated - aeb798c325cc33072ad090a1f8610bba4fdebaaa

2009-01-10 Thread Stefan (metze) Metzmacher
Jeremy Allison schrieb:
> On Fri, Jan 09, 2009 at 01:46:25AM -0600, Stefan Metzmacher wrote:
>> The branch, master has been updated
>>via  aeb798c325cc33072ad090a1f8610bba4fdebaaa (commit)
>>via  d524e5f4174e4f7578595bf6cd22a6d161b6e324 (commit)
>>via  def5e8e889e0ffe1cf55462ca32b69b627c5ff96 (commit)
>>   from  447f2668879e91990c985bdb8f0c5d5db2719a91 (commit)
>>
>> http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
>>
>>
>> - Log -
>> commit aeb798c325cc33072ad090a1f8610bba4fdebaaa
>> Author: Stefan Metzmacher 
>> Date:   Thu Jan 8 15:38:47 2009 +0100
>>
>> s3:smbd: handle incoming smb requests via event handlers
>> 
>> We use a fd event and receive incoming smb requests
>> when the fd becomes readable. It's not completely
>> nonblocking yet, but it should behave like the old code.
>> 
>> We use timed events to trigger retries for deferred open calls.
> 
> This is a nice piece of work Metze, thanks ! I was planning
> this also :-). Left TODO are the oplock signal handlers, and
> the message handlers, then I think we're completely driven
> by tevents.

Here's a start to make the irix oplock code event driven
http://gitweb.samba.org/?p=metze/samba/wip.git;a=shortlog;h=refs/heads/master3-tevent3
Then all fd and timer activity is based on the events system.

Then we can move the signal stuff.

> Great job !

Thanks!




signature.asc
Description: OpenPGP digital signature


Re: [SCM] Samba Shared Repository - branch master updated - aeb798c325cc33072ad090a1f8610bba4fdebaaa

2009-01-09 Thread Jeremy Allison
On Fri, Jan 09, 2009 at 01:46:25AM -0600, Stefan Metzmacher wrote:
> The branch, master has been updated
>via  aeb798c325cc33072ad090a1f8610bba4fdebaaa (commit)
>via  d524e5f4174e4f7578595bf6cd22a6d161b6e324 (commit)
>via  def5e8e889e0ffe1cf55462ca32b69b627c5ff96 (commit)
>   from  447f2668879e91990c985bdb8f0c5d5db2719a91 (commit)
> 
> http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
> 
> 
> - Log -
> commit aeb798c325cc33072ad090a1f8610bba4fdebaaa
> Author: Stefan Metzmacher 
> Date:   Thu Jan 8 15:38:47 2009 +0100
> 
> s3:smbd: handle incoming smb requests via event handlers
> 
> We use a fd event and receive incoming smb requests
> when the fd becomes readable. It's not completely
> nonblocking yet, but it should behave like the old code.
> 
> We use timed events to trigger retries for deferred open calls.

This is a nice piece of work Metze, thanks ! I was planning
this also :-). Left TODO are the oplock signal handlers, and
the message handlers, then I think we're completely driven
by tevents.

Great job !

Jeremy.


[SCM] Samba Shared Repository - branch master updated - aeb798c325cc33072ad090a1f8610bba4fdebaaa

2009-01-08 Thread Stefan Metzmacher
The branch, master has been updated
   via  aeb798c325cc33072ad090a1f8610bba4fdebaaa (commit)
   via  d524e5f4174e4f7578595bf6cd22a6d161b6e324 (commit)
   via  def5e8e889e0ffe1cf55462ca32b69b627c5ff96 (commit)
  from  447f2668879e91990c985bdb8f0c5d5db2719a91 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit aeb798c325cc33072ad090a1f8610bba4fdebaaa
Author: Stefan Metzmacher 
Date:   Thu Jan 8 15:38:47 2009 +0100

s3:smbd: handle incoming smb requests via event handlers

We use a fd event and receive incoming smb requests
when the fd becomes readable. It's not completely
nonblocking yet, but it should behave like the old code.

We use timed events to trigger retries for deferred open calls.

metze

commit d524e5f4174e4f7578595bf6cd22a6d161b6e324
Author: Stefan Metzmacher 
Date:   Thu Jan 8 19:45:13 2009 +0100

s3:events: debug sys_select() errors

metze

commit def5e8e889e0ffe1cf55462ca32b69b627c5ff96
Author: Stefan Metzmacher 
Date:   Thu Jan 8 15:16:51 2009 +0100

s3:events: install a tevent debug handler that calls DEBUG()

metze

---

Summary of changes:
 source3/include/smb.h  |2 +-
 source3/lib/events.c   |   46 -
 source3/smbd/globals.c |2 +
 source3/smbd/globals.h |6 +
 source3/smbd/process.c |  263 
 5 files changed, 209 insertions(+), 110 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/smb.h b/source3/include/smb.h
index 9f6a6f0..4d7d4b2 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -690,7 +690,7 @@ struct interface {
 struct pending_message_list {
struct pending_message_list *next, *prev;
struct timeval request_time; /* When was this first issued? */
-   struct timeval end_time; /* When does this time out? */
+   struct timed_event *te;
bool encrypted;
DATA_BLOB buf;
DATA_BLOB private_data;
diff --git a/source3/lib/events.c b/source3/lib/events.c
index c1feff8..8deaa18 100644
--- a/source3/lib/events.c
+++ b/source3/lib/events.c
@@ -189,6 +189,9 @@ static int s3_event_loop_once(struct tevent_context *ev)
ret = sys_select(maxfd+1, &r_fds, &w_fds, NULL, &to);
 
if (ret == -1 && errno != EINTR) {
+   tevent_debug(ev, TEVENT_DEBUG_FATAL,
+"sys_select() failed: %d:%s\n",
+errno, strerror(errno));
return -1;
}
 
@@ -274,8 +277,49 @@ static bool s3_tevent_init(void)
return initialized;
 }
 
+/*
+  this is used to catch debug messages from events
+*/
+static void s3_event_debug(void *context, enum tevent_debug_level level,
+  const char *fmt, va_list ap)  PRINTF_ATTRIBUTE(3,0);
+
+static void s3_event_debug(void *context, enum tevent_debug_level level,
+  const char *fmt, va_list ap)
+{
+   int samba_level = -1;
+   char *s = NULL;
+   switch (level) {
+   case TEVENT_DEBUG_FATAL:
+   samba_level = 0;
+   break;
+   case TEVENT_DEBUG_ERROR:
+   samba_level = 1;
+   break;
+   case TEVENT_DEBUG_WARNING:
+   samba_level = 2;
+   break;
+   case TEVENT_DEBUG_TRACE:
+   samba_level = 5;
+   break;
+
+   };
+   vasprintf(&s, fmt, ap);
+   if (!s) return;
+   DEBUG(samba_level, ("s3_event: %s", s));
+   free(s);
+}
+
 struct tevent_context *s3_tevent_context_init(TALLOC_CTX *mem_ctx)
 {
+   struct tevent_context *ev;
+
s3_tevent_init();
-   return tevent_context_init_byname(mem_ctx, "s3");
+
+   ev = tevent_context_init_byname(mem_ctx, "s3");
+   if (ev) {
+   tevent_set_debug(ev, s3_event_debug, NULL);
+   }
+
+   return ev;
 }
+
diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c
index ad017f5..6fcf18d 100644
--- a/source3/smbd/globals.c
+++ b/source3/smbd/globals.c
@@ -202,6 +202,8 @@ bool exit_firsttime = true;
 struct child_pid *children = 0;
 int num_children = 0;
 
+struct smbd_server_connection *smbd_server_conn = NULL;
+
 void smbd_init_globals(void)
 {
ZERO_STRUCT(char_flags);
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index 178263b..157089f 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -216,4 +216,10 @@ struct child_pid;
 extern struct child_pid *children;
 extern int num_children;
 
+struct smbd_server_connection {
+   struct fd_event *fde;
+   uint64_t num_requests;
+};
+extern struct smbd_server_connection *smbd_server_conn;
+
 void smbd_init_globals(void);
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 6f0a10d..1f24058 100644
--- a/source3/smbd/process.c
+++ b/source