diff options
author | Stefan Metzmacher <metze@samba.org> | 2011-11-22 10:10:30 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2011-11-29 16:00:08 +0100 |
commit | 04fa5b4957d4d668be612ded509d6d6c8070d270 (patch) | |
tree | 94a70056b26f58862780313e14db5ed6269f8fda /source4/libcli/smb2 | |
parent | 51a7201a12856a11695ecb1b769c31fedf984e9c (diff) | |
download | samba-04fa5b4957d4d668be612ded509d6d6c8070d270.tar.gz samba-04fa5b4957d4d668be612ded509d6d6c8070d270.tar.bz2 samba-04fa5b4957d4d668be612ded509d6d6c8070d270.zip |
s4:libcli/smb2: make sure only one idle event runs at a time
metze
Diffstat (limited to 'source4/libcli/smb2')
-rw-r--r-- | source4/libcli/smb2/smb2.h | 1 | ||||
-rw-r--r-- | source4/libcli/smb2/transport.c | 25 |
2 files changed, 17 insertions, 9 deletions
diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index e8ccdd9dc0..6d66e7a7e4 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -75,6 +75,7 @@ struct smb2_transport { void (*func)(struct smb2_transport *, void *); void *private_data; unsigned int period; + struct tevent_timer *te; } idle; struct { diff --git a/source4/libcli/smb2/transport.c b/source4/libcli/smb2/transport.c index 01f363b0a0..55281d2b49 100644 --- a/source4/libcli/smb2/transport.c +++ b/source4/libcli/smb2/transport.c @@ -438,12 +438,16 @@ static void idle_handler(struct tevent_context *ev, { struct smb2_transport *transport = talloc_get_type(private_data, struct smb2_transport); - struct timeval next = timeval_add(&t, 0, transport->idle.period); - tevent_add_timer(transport->ev, - transport, - next, - idle_handler, transport); + struct timeval next; + transport->idle.func(transport, transport->idle.private_data); + + next = timeval_current_ofs_usec(transport->idle.period); + transport->idle.te = tevent_add_timer(transport->ev, + transport, + next, + idle_handler, + transport); } /* @@ -455,12 +459,15 @@ void smb2_transport_idle_handler(struct smb2_transport *transport, uint64_t period, void *private_data) { + TALLOC_FREE(transport->idle.te); + transport->idle.func = idle_func; transport->idle.private_data = private_data; transport->idle.period = period; - tevent_add_timer(transport->ev, - transport, - timeval_current_ofs(0, period), - idle_handler, transport); + transport->idle.te = tevent_add_timer(transport->ev, + transport, + timeval_current_ofs_usec(period), + idle_handler, + transport); } |