I?m working on an OS project from github. There are two parts: Dovecot plugin - https://github.com/st3fan/dovecot-xaps-plugin Daemon written in Go - https://github.com/st3fan/dovecot-xaps-daemon # dovecot --version 2.2.10 Both parts worked fine on CentOS 6 but I recently rebuilt them both for CentOS 7 and have run into some errors. The plugin sends a notification over a socket to the daemon. The daemon then processes the request and returns a message to the plugin. The plugin reads the response then closes the socket and at that point, I?m running into an issue. The daemon reports the following: read unix /tmp/xapsd.sock->@: read: connection reset by peer In reading the Go language docs, it says that it will throw the first error it hits before the EOF from the socket. This led me to think that perhaps the plugin was not sending an EOF when closing the socket. I tried to write an EOF to the socket before the close but no change. Everything works between the plugin and daemon right up until the socket close. Is there a way to monitor the stream through the socket so I can see if the plugin is indeed sending the EOF? Knowing that lets me know if I need to chase down the issue in the Go daemon code. I?m no pro with C but I tried. The snippet from the plugin follows: alarm(1);?????????????? ??? { if (net_transmit(fd, str_data(req), str_len(req)) < 0) { ? i_error("write(%s) failed: %m", socket_path); ? ret = -1; } else { ? char res[1024]; ? ret = net_receive(fd, res, sizeof(res)-1); ? if (ret < 0) { ??????????????? i_error("read(%s) failed: %m", socket_path); ? } else { ??????????????? res[ret] = '\0'; ??????????????? if (strncmp(res, "OK ", 3) == 0) { ??????????????? ? ret = 0; ??????????????? } ? } } } alarm(0); char stx[1]; stx[0]=(char) 4; //stx[1]='\0'; if ( net_transmit(fd, stx, sizeof(stx) ) < 0 ) { ? i_error("Error writing EOF"); } //string_t *testEOF= t_str_new(2); //str_append(testEOF, (char*) 4); //if ( net_transmit(fd, str_data(testEOF), str_len(testEOF) ) < 0 ) { //????? i_error("Error writing EOF"); //??? } //i_close_fd(&fd); net_disconnect(fd); fd=-1; Thank you, Steffan Cline 602-793-0014
On 09/08/2017 02:29 AM, Steffan Cline wrote:> I???m working on an OS project from github. There are two parts: > > Dovecot plugin - https://github.com/st3fan/dovecot-xaps-plugin > > Daemon written in Go - https://github.com/st3fan/dovecot-xaps-daemon >what does this have to do with dovecot?>-- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com Being so tracked is for FARM ANIMALS and and extermination camps, but incompatible with living as a free human being. -RI Safir 2013
Hi! Nice to hear you are developing this, I'll add it to our wiki if it's not there. Please don't use net_transmit, it's going away. You should use ostream and istream instead. Aki On 08.09.2017 09:29, Steffan Cline wrote:> I?m working on an OS project from github. There are two parts: > > Dovecot plugin - https://github.com/st3fan/dovecot-xaps-plugin > > Daemon written in Go - https://github.com/st3fan/dovecot-xaps-daemon > > > > # dovecot --version > > 2.2.10 > > > > Both parts worked fine on CentOS 6 but I recently rebuilt them both for CentOS 7 and have run into some errors. > > > > The plugin sends a notification over a socket to the daemon. The daemon then processes the request and returns a message to the plugin. > > > > The plugin reads the response then closes the socket and at that point, I?m running into an issue. > > > > The daemon reports the following: read unix /tmp/xapsd.sock->@: read: connection reset by peer > > > > In reading the Go language docs, it says that it will throw the first error it hits before the EOF from the socket. This led me to think that perhaps the plugin was not sending an EOF when closing the socket. > > > > I tried to write an EOF to the socket before the close but no change. Everything works between the plugin and daemon right up until the socket close. > > > > Is there a way to monitor the stream through the socket so I can see if the plugin is indeed sending the EOF? Knowing that lets me know if I need to chase down the issue in the Go daemon code. > > > > I?m no pro with C but I tried. The snippet from the plugin follows: > > > > alarm(1); > > { > > if (net_transmit(fd, str_data(req), str_len(req)) < 0) { > > i_error("write(%s) failed: %m", socket_path); > > ret = -1; > > } else { > > char res[1024]; > > ret = net_receive(fd, res, sizeof(res)-1); > > if (ret < 0) { > > i_error("read(%s) failed: %m", socket_path); > > } else { > > res[ret] = '\0'; > > if (strncmp(res, "OK ", 3) == 0) { > > ret = 0; > > } > > } > > } > > } > > alarm(0); > > > > char stx[1]; > > stx[0]=(char) 4; > > //stx[1]='\0'; > > if ( net_transmit(fd, stx, sizeof(stx) ) < 0 ) { > > i_error("Error writing EOF"); > > } > > > > //string_t *testEOF= t_str_new(2); > > //str_append(testEOF, (char*) 4); > > //if ( net_transmit(fd, str_data(testEOF), str_len(testEOF) ) < 0 ) { > > // i_error("Error writing EOF"); > > // } > > > > //i_close_fd(&fd); > > net_disconnect(fd); > > fd=-1; > > > > > > > > Thank you, > > Steffan Cline > > 602-793-0014 > >
If you read the entire context you'll see code from a dovecot plugin and I'm trying to determine if dovecot is sending an EOF when closing the socket or not because the other end of the socket is at fault. From there I can check elsewhere. Dovecot code, dovecot list, made sense to try here first. Got any suggestions on how to check the socket traffic? Thanks, Steffan Cline steffan at hldns.com 602-793-0014> On Sep 7, 2017, at 11:42 PM, Ruben Safir <ruben at mrbrklyn.com> wrote: > >> On 09/08/2017 02:29 AM, Steffan Cline wrote: >> I???m working on an OS project from github. There are two parts: >> >> Dovecot plugin - https://github.com/st3fan/dovecot-xaps-plugin >> >> Daemon written in Go - https://github.com/st3fan/dovecot-xaps-daemon >> > > what does this have to do with dovecot? > >> > > > -- > So many immigrant groups have swept through our town > that Brooklyn, like Atlantis, reaches mythological > proportions in the mind of the world - RI Safir 1998 > http://www.mrbrklyn.com > > DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 > http://www.nylxs.com - Leadership Development in Free Software > http://www2.mrbrklyn.com/resources - Unpublished Archive > http://www.coinhangout.com - coins! > http://www.brooklyn-living.com > > Being so tracked is for FARM ANIMALS and and extermination camps, > but incompatible with living as a free human being. -RI Safir 2013 >
I'm not the originator. I'm just trying to do some maintenance on the code to make it work for CentOS 7. I'll check out those two. Any ideas on how to check exactly what's sent via the socket? If the EOF is sent, I know to dig further into the daemon code. Thanks, Steffan Cline steffan at hldns.com 602-793-0014> On Sep 7, 2017, at 11:43 PM, Aki Tuomi <aki.tuomi at dovecot.fi> wrote: > > Hi! > > Nice to hear you are developing this, I'll add it to our wiki if it's > not there. > > Please don't use net_transmit, it's going away. You should use ostream > and istream instead. > > Aki > > >> On 08.09.2017 09:29, Steffan Cline wrote: >> I?m working on an OS project from github. There are two parts: >> >> Dovecot plugin - https://github.com/st3fan/dovecot-xaps-plugin >> >> Daemon written in Go - https://github.com/st3fan/dovecot-xaps-daemon >> >> >> >> # dovecot --version >> >> 2.2.10 >> >> >> >> Both parts worked fine on CentOS 6 but I recently rebuilt them both for CentOS 7 and have run into some errors. >> >> >> >> The plugin sends a notification over a socket to the daemon. The daemon then processes the request and returns a message to the plugin. >> >> >> >> The plugin reads the response then closes the socket and at that point, I?m running into an issue. >> >> >> >> The daemon reports the following: read unix /tmp/xapsd.sock->@: read: connection reset by peer >> >> >> >> In reading the Go language docs, it says that it will throw the first error it hits before the EOF from the socket. This led me to think that perhaps the plugin was not sending an EOF when closing the socket. >> >> >> >> I tried to write an EOF to the socket before the close but no change. Everything works between the plugin and daemon right up until the socket close. >> >> >> >> Is there a way to monitor the stream through the socket so I can see if the plugin is indeed sending the EOF? Knowing that lets me know if I need to chase down the issue in the Go daemon code. >> >> >> >> I?m no pro with C but I tried. The snippet from the plugin follows: >> >> >> >> alarm(1); >> >> { >> >> if (net_transmit(fd, str_data(req), str_len(req)) < 0) { >> >> i_error("write(%s) failed: %m", socket_path); >> >> ret = -1; >> >> } else { >> >> char res[1024]; >> >> ret = net_receive(fd, res, sizeof(res)-1); >> >> if (ret < 0) { >> >> i_error("read(%s) failed: %m", socket_path); >> >> } else { >> >> res[ret] = '\0'; >> >> if (strncmp(res, "OK ", 3) == 0) { >> >> ret = 0; >> >> } >> >> } >> >> } >> >> } >> >> alarm(0); >> >> >> >> char stx[1]; >> >> stx[0]=(char) 4; >> >> //stx[1]='\0'; >> >> if ( net_transmit(fd, stx, sizeof(stx) ) < 0 ) { >> >> i_error("Error writing EOF"); >> >> } >> >> >> >> //string_t *testEOF= t_str_new(2); >> >> //str_append(testEOF, (char*) 4); >> >> //if ( net_transmit(fd, str_data(testEOF), str_len(testEOF) ) < 0 ) { >> >> // i_error("Error writing EOF"); >> >> // } >> >> >> >> //i_close_fd(&fd); >> >> net_disconnect(fd); >> >> fd=-1; >> >> >> >> >> >> >> >> Thank you, >> >> Steffan Cline >> >> 602-793-0014 >> >> >
Aki, Thanks for your direction! It seems that the issue I?m running into is this: https://www.dovecot.org/list/dovecot-cvs/2014-January/024154.html I?m told it?s fixed in 2.2.11 but CentOS 7?s repos have 2.2.10-7.el7. I found a work-around in the plugin at https://github.com/st3fan/dovecot-xaps-plugin/pull/15 without having to manually build the latest dovecot for the fix but think I?ll have to look into moving to ostream/istream. Do you know if ostream/istream are affected by that bug listed above? My goal is to make an RPM of the plugin and daemon that can be distributed eventually without having to alter the default version of doevcot in the repos. Thank you, Steffan Cline 602-793-0014 On 9/7/17, 11:43 PM, "dovecot on behalf of Aki Tuomi" <dovecot-bounces at dovecot.org on behalf of aki.tuomi at dovecot.fi> wrote: Hi! Nice to hear you are developing this, I'll add it to our wiki if it's not there. Please don't use net_transmit, it's going away. You should use ostream and istream instead. Aki On 08.09.2017 09:29, Steffan Cline wrote: > I?m working on an OS project from github. There are two parts: > > Dovecot plugin - https://github.com/st3fan/dovecot-xaps-plugin > > Daemon written in Go - https://github.com/st3fan/dovecot-xaps-daemon > > > > # dovecot --version > > 2.2.10 > > > > Both parts worked fine on CentOS 6 but I recently rebuilt them both for CentOS 7 and have run into some errors. > > > > The plugin sends a notification over a socket to the daemon. The daemon then processes the request and returns a message to the plugin. > > > > The plugin reads the response then closes the socket and at that point, I?m running into an issue. > > > > The daemon reports the following: read unix /tmp/xapsd.sock->@: read: connection reset by peer > > > > In reading the Go language docs, it says that it will throw the first error it hits before the EOF from the socket. This led me to think that perhaps the plugin was not sending an EOF when closing the socket. > > > > I tried to write an EOF to the socket before the close but no change. Everything works between the plugin and daemon right up until the socket close. > > > > Is there a way to monitor the stream through the socket so I can see if the plugin is indeed sending the EOF? Knowing that lets me know if I need to chase down the issue in the Go daemon code. > > > > I?m no pro with C but I tried. The snippet from the plugin follows: > > > > alarm(1); > > { > > if (net_transmit(fd, str_data(req), str_len(req)) < 0) { > > i_error("write(%s) failed: %m", socket_path); > > ret = -1; > > } else { > > char res[1024]; > > ret = net_receive(fd, res, sizeof(res)-1); > > if (ret < 0) { > > i_error("read(%s) failed: %m", socket_path); > > } else { > > res[ret] = '\0'; > > if (strncmp(res, "OK ", 3) == 0) { > > ret = 0; > > } > > } > > } > > } > > alarm(0); > > > > char stx[1]; > > stx[0]=(char) 4; > > //stx[1]='\0'; > > if ( net_transmit(fd, stx, sizeof(stx) ) < 0 ) { > > i_error("Error writing EOF"); > > } > > > > //string_t *testEOF= t_str_new(2); > > //str_append(testEOF, (char*) 4); > > //if ( net_transmit(fd, str_data(testEOF), str_len(testEOF) ) < 0 ) { > > // i_error("Error writing EOF"); > > // } > > > > //i_close_fd(&fd); > > net_disconnect(fd); > > fd=-1; > > > > > > > > Thank you, > > Steffan Cline > > 602-793-0014 > >