|
|
b69e47 |
From 645e628626f4a3d4b662c067584b4efc6b5c70c5 Mon Sep 17 00:00:00 2001
|
|
|
b69e47 |
From: William Brown <firstyear@redhat.com>
|
|
|
b69e47 |
Date: Wed, 15 Mar 2017 10:46:38 +1000
|
|
|
b69e47 |
Subject: [PATCH 5/5] Ticket 49171 - Nunc Stans incorrectly reports a timeout
|
|
|
b69e47 |
|
|
|
b69e47 |
Bug Description: In some cases nunc-stans would incorrectly report
|
|
|
b69e47 |
and IO timeout.
|
|
|
b69e47 |
|
|
|
b69e47 |
Fix Description: Make the io output type volatile to prevent re-arranging
|
|
|
b69e47 |
of the code. We then make timeout exclusive to read, write and signal.
|
|
|
b69e47 |
Finally, we add an extra check into ns_handle_pr_read_ready that
|
|
|
b69e47 |
asserts we truly have an idle timeout. It issues a warning now
|
|
|
b69e47 |
instead if this scenario occurs, rather than closing the
|
|
|
b69e47 |
connection.
|
|
|
b69e47 |
|
|
|
b69e47 |
https://pagure.io/389-ds-base/issue/49171
|
|
|
b69e47 |
|
|
|
b69e47 |
Author: wibrown
|
|
|
b69e47 |
|
|
|
b69e47 |
Review by: mreynolds (thanks!)
|
|
|
b69e47 |
|
|
|
b69e47 |
(cherry picked from commit c8ce1b32cc365174c8280111c2d55bba45f7949f)
|
|
|
b69e47 |
---
|
|
|
b69e47 |
ldap/servers/slapd/daemon.c | 15 +++++++++++----
|
|
|
b69e47 |
src/nunc-stans/ns/ns_event_fw_event.c | 28 ++++++++++++++++------------
|
|
|
b69e47 |
2 files changed, 27 insertions(+), 16 deletions(-)
|
|
|
b69e47 |
|
|
|
b69e47 |
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
|
|
|
b69e47 |
index a37c8c6..6b3331d 100644
|
|
|
b69e47 |
--- a/ldap/servers/slapd/daemon.c
|
|
|
b69e47 |
+++ b/ldap/servers/slapd/daemon.c
|
|
|
b69e47 |
@@ -1970,11 +1970,18 @@ ns_handle_pr_read_ready(struct ns_job_t *job)
|
|
|
b69e47 |
connection_release_nolock_ext(c, 1); /* release ref acquired when job was added */
|
|
|
b69e47 |
if (CONN_NEEDS_CLOSING(c)) {
|
|
|
b69e47 |
ns_handle_closure_nomutex(c);
|
|
|
b69e47 |
+ /* We shouldn't need the c_idletimeout check here because of how libevent works.
|
|
|
b69e47 |
+ * consider testing this and removing it oneday.
|
|
|
b69e47 |
+ */
|
|
|
b69e47 |
} else if (NS_JOB_IS_TIMER(ns_job_get_output_type(job))) {
|
|
|
b69e47 |
- /* idle timeout */
|
|
|
b69e47 |
- disconnect_server_nomutex_ext(c, c->c_connid, -1,
|
|
|
b69e47 |
- SLAPD_DISCONNECT_IDLE_TIMEOUT, EAGAIN,
|
|
|
b69e47 |
- 0 /* do not schedule closure, do it next */);
|
|
|
b69e47 |
+ if (c->c_idletimeout > 0) {
|
|
|
b69e47 |
+ /* idle timeout */
|
|
|
b69e47 |
+ disconnect_server_nomutex_ext(c, c->c_connid, -1,
|
|
|
b69e47 |
+ SLAPD_DISCONNECT_IDLE_TIMEOUT, EAGAIN,
|
|
|
b69e47 |
+ 0 /* do not schedule closure, do it next */);
|
|
|
b69e47 |
+ } else {
|
|
|
b69e47 |
+ slapi_log_err(SLAPI_LOG_WARNING, "ns_handle_pr_read_ready", "Received idletime out with c->c_idletimeout as 0. Ignoring.\n");
|
|
|
b69e47 |
+ }
|
|
|
b69e47 |
ns_handle_closure_nomutex(c);
|
|
|
b69e47 |
} else if ((connection_activity(c, maxthreads)) == -1) {
|
|
|
b69e47 |
/* This might happen as a result of
|
|
|
b69e47 |
diff --git a/src/nunc-stans/ns/ns_event_fw_event.c b/src/nunc-stans/ns/ns_event_fw_event.c
|
|
|
b69e47 |
index 58dac28..3acbaf7 100644
|
|
|
b69e47 |
--- a/src/nunc-stans/ns/ns_event_fw_event.c
|
|
|
b69e47 |
+++ b/src/nunc-stans/ns/ns_event_fw_event.c
|
|
|
b69e47 |
@@ -71,18 +71,22 @@ event_logger_cb(int severity, const char *msg)
|
|
|
b69e47 |
static ns_job_type_t
|
|
|
b69e47 |
event_flags_to_type(short events)
|
|
|
b69e47 |
{
|
|
|
b69e47 |
- ns_job_type_t job_type = 0;
|
|
|
b69e47 |
- if (events & EV_READ) {
|
|
|
b69e47 |
- job_type |= NS_JOB_READ;
|
|
|
b69e47 |
- }
|
|
|
b69e47 |
- if (events & EV_WRITE) {
|
|
|
b69e47 |
- job_type |= NS_JOB_WRITE;
|
|
|
b69e47 |
- }
|
|
|
b69e47 |
- if (events & EV_TIMEOUT) {
|
|
|
b69e47 |
- job_type |= NS_JOB_TIMER;
|
|
|
b69e47 |
- }
|
|
|
b69e47 |
- if (events & EV_SIGNAL) {
|
|
|
b69e47 |
- job_type |= NS_JOB_SIGNAL;
|
|
|
b69e47 |
+ /* The volatile here prevents gcc rearranging this code within the thread. */
|
|
|
b69e47 |
+ volatile ns_job_type_t job_type = 0;
|
|
|
b69e47 |
+
|
|
|
b69e47 |
+ /* Either we timeout *or* we are a real event */
|
|
|
b69e47 |
+ if (!(events & EV_TIMEOUT)) {
|
|
|
b69e47 |
+ if (events & EV_READ) {
|
|
|
b69e47 |
+ job_type |= NS_JOB_READ;
|
|
|
b69e47 |
+ }
|
|
|
b69e47 |
+ if (events & EV_WRITE) {
|
|
|
b69e47 |
+ job_type |= NS_JOB_WRITE;
|
|
|
b69e47 |
+ }
|
|
|
b69e47 |
+ if (events & EV_SIGNAL) {
|
|
|
b69e47 |
+ job_type |= NS_JOB_SIGNAL;
|
|
|
b69e47 |
+ }
|
|
|
b69e47 |
+ } else {
|
|
|
b69e47 |
+ job_type = NS_JOB_TIMER;
|
|
|
b69e47 |
}
|
|
|
b69e47 |
return job_type;
|
|
|
b69e47 |
}
|
|
|
b69e47 |
--
|
|
|
b69e47 |
2.9.3
|
|
|
b69e47 |
|