1 #include <lib/base/filepush.h>
2 #include <lib/base/eerror.h>
5 eFilePushThread::eFilePushThread()
8 m_buf_start = m_buf_end = 0;
11 static void signal_handler(int x)
15 void eFilePushThread::thread()
17 eDebug("FILEPUSH THREAD START");
18 // this is a race. FIXME.
20 /* we set the signal to not restart syscalls, so we can detect our signal. */
22 act.sa_handler = signal_handler; // no, SIG_IGN doesn't do it. we want to receive the -EINTR
24 sigaction(SIGUSR1, &act, 0);
26 /* m_stop must be evaluated after each syscall. */
29 /* first try flushing the bufptr */
30 if (m_buf_start != m_buf_end)
32 // TODO: take care of boundaries.
33 int w = write(m_fd_dest, m_buffer + m_buf_start, m_buf_end - m_buf_start);
38 eDebug("eFilePushThread *write error* - not yet handled");
39 // ... we would stop the thread
41 // printf("FILEPUSH: wrote %d bytes\n", w);
46 /* now fill our buffer. */
48 m_buf_end = read(m_fd_source, m_buffer, sizeof(m_buffer));
54 eDebug("eFilePushThread *read error* - not yet handled");
58 eDebug("FILEPUSH: end-of-file! (currently unhandled)");
61 // printf("FILEPUSH: read %d bytes\n", m_buf_end);
64 eDebug("FILEPUSH THREAD STOP");
67 void eFilePushThread::start(int fd_source, int fd_dest)
69 m_fd_source = fd_source;
75 void eFilePushThread::stop()