Skip to content

Commit 6a7f95e

Browse files
committed
Send disconnect message to the server
1 parent 3060cc4 commit 6a7f95e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

contrib/pg_dtm/sockhub/sockhub.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <unistd.h>
1515
#include <string.h>
1616
#include <errno.h>
17-
#include <assert.h>
1817

1918
#include "sockhub.h"
2019

@@ -155,12 +154,18 @@ static void reconnect(Shub* shub)
155154
static void notify_disconnect(Shub* shub, int chan)
156155
{
157156
ShubMessageHdr* hdr;
158-
assert(shub->in_buffer_used + sizeof(ShubMessageHdr) < shub->params->buffer_size);
159157
hdr = (ShubMessageHdr*)&shub->in_buffer[shub->in_buffer_used];
160158
hdr->size = 0;
161159
hdr->chan = chan;
162160
hdr->code = MSG_DISCONNECT;
163161
shub->in_buffer_used += sizeof(ShubMessageHdr);
162+
if (shub->in_buffer_used + sizeof(ShubMessageHdr) > shub->params->buffer_size) {
163+
while (!write_socket(shub->output, shub->in_buffer, shub->in_buffer_used)) {
164+
shub->params->error_handler("Failed to write to inet socket", SHUB_RECOVERABLE_ERROR);
165+
reconnect(shub);
166+
}
167+
shub->in_buffer_used = 0;
168+
}
164169
}
165170

166171
static void recovery(Shub* shub)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy