summaryrefslogtreecommitdiff
path: root/main/manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/manager.c')
-rw-r--r--main/manager.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/main/manager.c b/main/manager.c
index 328878251..5e74fb5a8 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -1769,6 +1769,15 @@ static void session_destructor(void *obj)
}
if (session->f != NULL) {
+ /*
+ * Issuing shutdown() is necessary here to avoid a race
+ * condition where the last data written may not appear
+ * in the the TCP stream. See ASTERISK-23548
+ */
+ fflush(session->f);
+ if (session->fd != -1) {
+ shutdown(session->fd, SHUT_RDWR);
+ }
fclose(session->f);
}
if (eqe) {
@@ -6740,12 +6749,21 @@ static void process_output(struct mansession *s, struct ast_str **out, struct as
}
if (s->f) {
+ /*
+ * Issuing shutdown() is necessary here to avoid a race
+ * condition where the last data written may not appear
+ * in the the TCP stream. See ASTERISK-23548
+ */
+ if (s->fd != -1) {
+ shutdown(s->fd, SHUT_RDWR);
+ }
if (fclose(s->f)) {
ast_log(LOG_ERROR, "fclose() failed: %s\n", strerror(errno));
}
s->f = NULL;
s->fd = -1;
} else if (s->fd != -1) {
+ shutdown(s->fd, SHUT_RDWR);
if (close(s->fd)) {
ast_log(LOG_ERROR, "close() failed: %s\n", strerror(errno));
}