<div dir="ltr">Shawn<div><br></div><div>An alternative to "waiting a tad" might be to flush the queue. Apparently this can be done by disabling the Nagle algorithm that is designed to collect multiple chunks in a single TCP segment. It appears that you can disable Nagle and re-enable it again, to effectively flush the output queue. A bit more info here:</div><div><br></div><div><a href="https://stackoverflow.com/questions/855544/is-there-a-way-to-flush-a-posix-socket">https://stackoverflow.com/questions/855544/is-there-a-way-to-flush-a-posix-socket</a><br></div><div><br></div><div>So you might do something like this (although please note that I'm nto a C programmer):</div><div><br></div><div>+               else if (strncmp(l, "flush", 5) == 0) {</div><div>+                       int flag=0;<br>+                       <span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit;font-size:13px">setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (</span><span class="gmail-hljs-keyword" style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;font-size:13px;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit">char</span><span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit;font-size:13px"> *) &flag, </span><span class="gmail-hljs-keyword" style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;font-size:13px;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit">sizeof</span><span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit;font-size:13px">(</span><span class="gmail-hljs-keyword" style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;font-size:13px;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit">int</span><span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit;font-size:13px">))</span>;</div>+                       int flag=1;<br><div>+                       <span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit;font-size:13px">setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (</span><span class="gmail-hljs-keyword" style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;font-size:13px;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit">char</span><span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit;font-size:13px"> *) &flag, </span><span class="gmail-hljs-keyword" style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;font-size:13px;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit">sizeof</span><span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit;font-size:13px">(</span><span class="gmail-hljs-keyword" style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;font-size:13px;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit">int</span><span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit;font-size:13px">))</span>;</div><div>+               }<br></div><div><br></div><div>Having said that, I don't think this is going to work. The netservices.c file you're trying to patch is only used when reading the config file. This is probably why your delay is not affecting the connection - it's probably delaying only the reading of the configuration file.</div><div><br></div><div>I think the file that does the sending is contest.c. I can't see a simple way of disabling and re-enabling Nagle (as above) at a specific stage in the dialogue. However it might be possible, notwithstanding the bug that Ralf mentioned, to introduce a sleep at the point that data are written (eg after socket(write)).</div><div><br></div><div>Cheers</div><div>Jeremy</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 30 May 2021 at 10:19, Ralph M <<a href="mailto:ralphmitchell@gmail.com">ralphmitchell@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">As far as the sleep() thing goes, you may be running into this, from the 'man 3 sleep' man page:<div><br></div><div>   BUGS<br>          sleep()  may be implemented using SIGALRM; mixing calls to alarm(2) and<br>          sleep() is a bad idea.<br></div><div><br></div><div>I don't know how you'd fix it.  Hopefully this gives you a starting point.</div><div><br></div><div>Ralph Mitchell</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, May 29, 2021 at 4:11 PM Shawn Heisey <<a href="mailto:hobbit@elyograg.org" target="_blank">hobbit@elyograg.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Over ten years ago, I asked on this list how I could get rid of the <br>
"incorrect pipelining message" logged by postfix every time the smtp, <br>
smtps, or submission tests are done.<br>
<br>
<a href="https://lists.xymon.com/oldarchive/2010/11/msg00207.html" rel="noreferrer" target="_blank">https://lists.xymon.com/oldarchive/2010/11/msg00207.html</a><br>
<br>
The fix that I claim worked (multiple send commands) was for a job I had <br>
at the time.  Now I am have a personal mail server (that also runs <br>
xymon) and that fix I mentioned so long ago is not working.<br>
<br>
I tweaked the code to allow a "pause" action in protocols.cfg and after <br>
modifying protocols.cfg to utilize it, I have eliminated the "incorrect <br>
command pipelining" message in mail.log.  Here's the patch:<br>
<br>
--- xymon-4.3.28/lib/netservices.c      2017-01-05 19:00:06.000000000 -0700<br>
+++ pause-xymon-4.3.28/lib/netservices.c        2021-05-29 <br>
12:51:09.717461323 -0600<br>
@@ -259,6 +259,10 @@<br>
                                 }<br>
                         }<br>
                 }<br>
+               else if (strncmp(l, "pause ", 6) == 0) {<br>
+                       int pausetime = atoi(skipwhitespace(l+5));<br>
+                       sleep(pausetime);<br>
+               }<br>
         }<br>
<br>
         if (fd) stackfclose(fd);<br>
<br>
Here's the new definitions I created in protocols.cfg:<br>
<br>
[smtp]<br>
    pause 2<br>
    send "ehlo xymonnet.localdomain\r\n"<br>
    pause 2<br>
    send "mail\r\n"<br>
    pause 2<br>
    send "quit\r\n"<br>
    expect "220"<br>
    options banner<br>
    port 25<br>
<br>
[smtps]<br>
    pause 2<br>
    send "ehlo xymonnet.localdomain\r\n"<br>
    pause 2<br>
    send "mail\r\n"<br>
    pause 2<br>
    send "quit\r\n"<br>
    expect "220"<br>
    options ssl,banner<br>
#  No default port-number assignment for smtps - nonstandard according <br>
to IANA<br>
<br>
[submission|msa]<br>
    pause 2<br>
    send "ehlo xymonnet.localdomain\r\n"<br>
    pause 2<br>
    send "mail\r\n"<br>
    pause 2<br>
    send "quit\r\n"<br>
    expect "220"<br>
    options banner<br>
    port 587<br>
<br>
<br>
And this is now what I see in mail.log (testing smtps and submission:<br>
<br>
May 29 13:51:15 bilbo postfix/submission/smtpd[16324]: connect from <br>
<a href="http://bilbo.elyograg.org" rel="noreferrer" target="_blank">bilbo.elyograg.org</a>[172.31.8.104]<br>
May 29 13:51:15 bilbo postfix/submission/smtpd[16324]: disconnect from <br>
<a href="http://bilbo.elyograg.org" rel="noreferrer" target="_blank">bilbo.elyograg.org</a>[172.31.8.104] quit=1 commands=1<br>
May 29 13:51:15 bilbo postfix/smtps/smtpd[16325]: connect from <br>
<a href="http://bilbo.elyograg.org" rel="noreferrer" target="_blank">bilbo.elyograg.org</a>[172.31.8.104]<br>
May 29 13:51:15 bilbo postfix/smtps/smtpd[16325]: disconnect from <br>
<a href="http://bilbo.elyograg.org" rel="noreferrer" target="_blank">bilbo.elyograg.org</a>[172.31.8.104] quit=1 commands=1<br>
<br>
Interesting thing here is that it's not actually pausing.  Which <br>
probably means that I implemented it incorrectly.  My training on C is <br>
ancient and I'm very rusty.  But even though it doesn't pause, the error <br>
is gone, simply because each smtp command is now sent in a separate <br>
packet, which appears to *sometimes* be enough "delay" for postfix to <br>
not complain about pipelining.  What happens now is occasionally I will <br>
get a yellow status on smtps with the xymon UI saying "Service smtps on <br>
<a href="http://bilbo.elyograg.org" rel="noreferrer" target="_blank">bilbo.elyograg.org</a> is not OK : Unexpected service response".<br>
<br>
So I think what I will do before submitting a patch is implement a <br>
"null" action (which will do nothing) as well as a "pause" action, and <br>
get some help from the real C developers here for making "pause" behave <br>
as advertised.  Can somebody point me to some instructions on properly <br>
creating and submitting a patch?  Also, if I could get some info on any <br>
other files I need to modify (man pages, readme files, etc), I would <br>
really appreciate it.<br>
<br>
Thanks,<br>
Shawn<br>
_______________________________________________<br>
Xymon mailing list<br>
<a href="mailto:Xymon@xymon.com" target="_blank">Xymon@xymon.com</a><br>
<a href="http://lists.xymon.com/mailman/listinfo/xymon" rel="noreferrer" target="_blank">http://lists.xymon.com/mailman/listinfo/xymon</a><br>
</blockquote></div>
_______________________________________________<br>
Xymon mailing list<br>
<a href="mailto:Xymon@xymon.com" target="_blank">Xymon@xymon.com</a><br>
<a href="http://lists.xymon.com/mailman/listinfo/xymon" rel="noreferrer" target="_blank">http://lists.xymon.com/mailman/listinfo/xymon</a><br>
</blockquote></div>