roxen.lists.pike.general

Subject Author Date
pike@roxen.com Marc Dirix <marc[at]electronics-design[dot]nl> 21-01-2009
Hi,

Currently I'm running Pike 7.7 release 39 on this server.
In my IMAP module I connect to a IMAP socket. The IMAP module
uses both blocking and non-blocking communication on the socket.

For some reason the call to fd->set_blocking_keep_callbacks() does
not work. As data arives on the socket the callback is still called.
This is part of the code I used:

private void _send ( int reqid, string _Command, mixed ... args)
{

   fd->set_blocking_keep_callbacks();
   fd->write ( sprintf( "A%04d "+_Command+"\n", reqid, @args) );
   Stdio.FILE bufferfd = Stdio.FILE();
   bufferfd->assign(fd->dup());
   string data;
   while(data=bufferfd->gets())
   {
      process(data);
      break;
   }
   fd->set_nonblocking_keep_callbacks();
}

In this case however between the fd->write and data=bufferfd->gets()
the read-callback is called with the data I'd expect to gets().

If I change this code the code below it works as expected:

private void _send ( int reqid, string _Command, mixed ... args)
{

   fd->set_blocking();
   fd->write ( sprintf( "A%04d "+_Command+"\n", reqid, @args) );
   Stdio.FILE bufferfd = Stdio.FILE();
   bufferfd->assign(fd->dup());
   string data;
   while(data=bufferfd->gets())
   {
      process(data);
      break;
   }
   fd->set_nonblocking(_async_read_cb,0,_async_close_cb);
}


Any thoughts?

Marc