LGTM. RB+ and pushed !
Post by Volker Lendecke via samba-technical--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
From 1f67e158744d0e68b8f20748976737c52fe9f157 Mon Sep 17 00:00:00 2001
Date: Mon, 23 Apr 2018 15:36:28 +0200
Subject: [PATCH 1/2] tevent: Fix callers of tevent_req_set_endtime
tevent_req_set_endtime internally already calls tevent_req_nomem and thus sets
the error status correctly.
---
lib/tevent/tevent.h | 3 ++-
libcli/cldap/cldap.c | 1 -
libcli/dns/dns.c | 1 -
source3/lib/g_lock.c | 2 --
source3/lib/util_sock.c | 1 -
source3/libsmb/namequery.c | 4 ----
source4/libcli/smb2/session.c | 1 -
7 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h
index 7bb9c618b2b..3ccac6a3600 100644
--- a/lib/tevent/tevent.h
+++ b/lib/tevent/tevent.h
@@ -1026,7 +1026,8 @@ struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
#endif
/**
+ * set to state TEVENT_REQ_NO_MEMORY.
*
*
diff --git a/libcli/cldap/cldap.c b/libcli/cldap/cldap.c
index 242a1173017..daba37a21d7 100644
--- a/libcli/cldap/cldap.c
+++ b/libcli/cldap/cldap.c
@@ -663,7 +663,6 @@ struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
}
if (!tevent_req_set_endtime(req, state->caller.ev, end)) {
- tevent_req_oom(req);
goto post;
}
diff --git a/libcli/dns/dns.c b/libcli/dns/dns.c
index c30de2d4add..1321b1d2d38 100644
--- a/libcli/dns/dns.c
+++ b/libcli/dns/dns.c
@@ -97,7 +97,6 @@ static struct tevent_req *dns_udp_request_send(TALLOC_CTX *mem_ctx,
if (!tevent_req_set_endtime(req, ev,
timeval_current_ofs(DNS_REQUEST_TIMEOUT, 0))) {
- tevent_req_oom(req);
return tevent_req_post(req, ev);
}
diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c
index 9ce0e062275..bffbd6bab4d 100644
--- a/source3/lib/g_lock.c
+++ b/source3/lib/g_lock.c
@@ -387,7 +387,6 @@ struct tevent_req *g_lock_lock_send(TALLOC_CTX *mem_ctx,
if (!tevent_req_set_endtime(
fn_state.watch_req, state->ev,
timeval_current_ofs(5 + sys_random() % 5, 0))) {
- tevent_req_oom(req);
return tevent_req_post(req, ev);
}
tevent_req_set_callback(fn_state.watch_req, g_lock_lock_retry, req);
@@ -441,7 +440,6 @@ static void g_lock_lock_retry(struct tevent_req *subreq)
if (!tevent_req_set_endtime(
fn_state.watch_req, state->ev,
timeval_current_ofs(5 + sys_random() % 5, 0))) {
- tevent_req_oom(req);
return;
}
tevent_req_set_callback(fn_state.watch_req, g_lock_lock_retry, req);
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index c74fcd9138d..c97babeebe3 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -577,7 +577,6 @@ static void open_socket_out_connected(struct tevent_req *subreq)
if (!tevent_req_set_endtime(
subreq, state->ev,
timeval_current_ofs_usec(state->wait_usec))) {
- tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
return;
}
state->connect_subreq = subreq;
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 8c23f09f442..d2ce78675ff 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -1666,7 +1666,6 @@ static struct tevent_req *name_queries_send(
if (!tevent_req_set_endtime(
subreq, state->ev,
timeval_current_ofs(0, state->timeout_msec * 1000))) {
- tevent_req_oom(req);
return tevent_req_post(req, ev);
}
tevent_req_set_callback(subreq, name_queries_done, req);
@@ -1749,7 +1748,6 @@ static void name_queries_next(struct tevent_req *subreq)
if (!tevent_req_set_endtime(
subreq, state->ev,
timeval_current_ofs(0, state->timeout_msec * 1000))) {
- tevent_req_oom(req);
return;
}
state->subreqs[state->num_sent] = subreq;
@@ -1986,7 +1984,6 @@ static struct tevent_req *query_wins_list_send(
}
if (!tevent_req_set_endtime(subreq, state->ev,
timeval_current_ofs(2, 0))) {
- tevent_req_oom(req);
return tevent_req_post(req, ev);
}
tevent_req_set_callback(subreq, query_wins_list_done, req);
@@ -2033,7 +2030,6 @@ static void query_wins_list_done(struct tevent_req *subreq)
}
if (!tevent_req_set_endtime(subreq, state->ev,
timeval_current_ofs(2, 0))) {
- tevent_req_oom(req);
return;
}
tevent_req_set_callback(subreq, query_wins_list_done, req);
diff --git a/source4/libcli/smb2/session.c b/source4/libcli/smb2/session.c
index e3e54cbe31a..b2cb8384f95 100644
--- a/source4/libcli/smb2/session.c
+++ b/source4/libcli/smb2/session.c
@@ -163,7 +163,6 @@ struct tevent_req *smb2_session_setup_spnego_send(
ok = tevent_req_set_endtime(req, ev, endtime);
if (!ok) {
- tevent_req_oom(req);
return tevent_req_post(req, ev);
}
--
2.11.0
From f3b8ee948afebc7d8787e9614a48f0c52d748994 Mon Sep 17 00:00:00 2001
Date: Tue, 24 Apr 2018 14:19:48 +0200
Subject: [PATCH 2/2] lib: #include "util_event.h" only where needed
One dependency of includes.h less
---
source3/include/includes.h | 1 -
source3/include/util_event.h | 4 ++++
source3/lib/util_event.c | 1 +
source3/printing/queue_process.c | 1 +
source3/smbd/process.c | 1 +
5 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/source3/include/includes.h b/source3/include/includes.h
index d822c3f9300..9c47c342bba 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -260,7 +260,6 @@ typedef char fstring[FSTRING_LEN];
#include <talloc.h>
#include <tevent.h>
-#include "util_event.h"
#include "../lib/util/data_blob.h"
#include "../lib/util/time.h"
diff --git a/source3/include/util_event.h b/source3/include/util_event.h
index f29bb0a9ed4..d19678e7359 100644
--- a/source3/include/util_event.h
+++ b/source3/include/util_event.h
@@ -19,6 +19,10 @@
*/
/* The following definitions come from lib/util_event.c */
+
+#include "replace.h"
+#include <tevent.h>
+
struct idle_event;
struct idle_event *event_add_idle(struct tevent_context *event_ctx,
diff --git a/source3/lib/util_event.c b/source3/lib/util_event.c
index 4ca2840b661..ea7e7b749ea 100644
--- a/source3/lib/util_event.c
+++ b/source3/lib/util_event.c
@@ -19,6 +19,7 @@
*/
#include "includes.h"
+#include "util_event.h"
struct idle_event {
struct tevent_timer *te;
diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c
index 24708c19537..c4941d84ccd 100644
--- a/source3/printing/queue_process.c
+++ b/source3/printing/queue_process.c
@@ -34,6 +34,7 @@
#include "rpc_server/spoolss/srv_spoolss_nt.h"
#include "auth.h"
#include "nt_printing.h"
+#include "util_event.h"
extern pid_t start_spoolssd(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx);
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 516ac4cb290..6a3395ceabf 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -43,6 +43,7 @@
#include "lib/util/sys_rw_data.h"
#include "system/threads.h"
#include "lib/pthreadpool/pthreadpool_tevent.h"
+#include "util_event.h"
/* Internal message queue for deferred opens. */
struct pending_message_list {
--
2.11.0