EOF from net_disconnect(fd)

Steffan Cline steffan at hldns.com
Fri Sep 8 19:10:48 EEST 2017


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
    >
    >  
    
    




More information about the dovecot mailing list