this fixed the correct handling of the default main loop
but setting another DefaultTimeout isn't nice. I've to look later again into the problem. Maybe I did it wrong. Currently there's a compiler warning that could be ignores as long as Slot is created with void parameter, but I consider this as bug in the long time and I've to fix it!!
This commit is contained in:
parent
9af6f707eb
commit
dc833f4a89
8 changed files with 54 additions and 31 deletions
|
@ -103,20 +103,14 @@ void BusDispatcher::enter()
|
|||
++p_it)
|
||||
{
|
||||
Pipe* read_pipe = *p_it;
|
||||
char buf;
|
||||
char buf_str[1024];
|
||||
int i = 0;
|
||||
char buffer[1024]; // TODO: should be max pipe size
|
||||
unsigned int nbytes = 0;
|
||||
|
||||
while (read_pipe->read((void*) &buf, 1) > 0)
|
||||
{
|
||||
buf_str[i] = buf;
|
||||
++i;
|
||||
}
|
||||
while (read_pipe->read(buffer, nbytes) > 0)
|
||||
{
|
||||
read_pipe->_handler (read_pipe->_data, buffer, nbytes);
|
||||
}
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
read_pipe->_handler (read_pipe->_data, buf_str, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <dbus/dbus.h>
|
||||
|
||||
using namespace DBus;
|
||||
using namespace std;
|
||||
|
||||
static double millis(timeval tv)
|
||||
{
|
||||
|
|
14
src/pipe.cpp
14
src/pipe.cpp
|
@ -35,6 +35,7 @@
|
|||
#include <sys/poll.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <cassert>
|
||||
|
||||
using namespace DBus;
|
||||
using namespace std;
|
||||
|
@ -52,7 +53,6 @@ Pipe::Pipe(void(*handler)(const void *data, void *buffer, unsigned int nbyte), c
|
|||
_fd_read = fd[0];
|
||||
_fd_write = fd[1];
|
||||
fcntl(_fd_read, F_SETFL, O_NONBLOCK);
|
||||
fcntl(_fd_write, F_SETFL, O_NONBLOCK);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -62,11 +62,19 @@ Pipe::Pipe(void(*handler)(const void *data, void *buffer, unsigned int nbyte), c
|
|||
|
||||
void Pipe::write(const void *buffer, unsigned int nbytes)
|
||||
{
|
||||
// first write the size into the pipe...
|
||||
::write(_fd_write, static_cast <const void*> (&nbytes), sizeof(nbytes));
|
||||
|
||||
// ...then write the real data
|
||||
::write(_fd_write, buffer, nbytes);
|
||||
}
|
||||
|
||||
ssize_t Pipe::read(void *buffer, unsigned int nbytes)
|
||||
{
|
||||
ssize_t Pipe::read(void *buffer, unsigned int &nbytes)
|
||||
{
|
||||
// first read the size from the pipe...
|
||||
::read(_fd_read, &nbytes, sizeof (nbytes));
|
||||
|
||||
//ssize_t size = 0;
|
||||
return ::read(_fd_read, buffer, nbytes);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue