VM_ThreadLoop select() silently restarted when EINTR
[gnokii.git] / common / data / datapump.c
index 4eede53..adb201d 100644 (file)
@@ -14,6 +14,8 @@
 
 */
 
+#include "config.h"
+
 #define                __data_datapump_c
 
 
@@ -27,7 +29,9 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef UCLINUX
 #include <sys/poll.h>
+#endif
 #include <unistd.h>
 
 
 extern bool CommandMode;
 
 /* Local variables */
-int            PtyRDFD;        /* File descriptor for reading and writing to/from */
-int            PtyWRFD;        /* pty interface - only different in debug mode. */ 
-struct pollfd ufds;
-u8 pluscount;
-bool connected;
+extern int             PtyRDFD;        /* File descriptor for reading and writing to/from */
+extern int             PtyWRFD;        /* pty interface - only different in debug mode. */ 
+static u8 pluscount;
+static bool connected;
+
+static int DP_CallBack(RLP_UserInds ind, u8 *buffer, int length);
 
 bool DP_Initialise(int read_fd, int write_fd)
 {
        PtyRDFD = read_fd;
        PtyWRFD = write_fd;
-       ufds.fd=PtyRDFD;
-       ufds.events=POLLIN;
        RLP_Initialise(GSM->SendRLPFrame, DP_CallBack);
        RLP_SetUserRequest(Attach_Req,true);
        pluscount=0;
@@ -63,7 +66,7 @@ bool DP_Initialise(int read_fd, int write_fd)
 }
 
 
-int DP_CallBack(RLP_UserInds ind, u8 *buffer, int length)
+static int DP_CallBack(RLP_UserInds ind, u8 *buffer, int length)
 {
        int temp;
 
@@ -91,15 +94,23 @@ int DP_CallBack(RLP_UserInds ind, u8 *buffer, int length)
        case Reset_Ind:
                RLP_SetUserRequest(Reset_Resp,true);
                break;
-       case GetData:
-               if (poll(&ufds,1,0)) {
+       case GetData: {
+               fd_set readfds;
+               struct timeval timeout;
+
+               FD_ZERO(&readfds);
+               FD_SET(PtyRDFD,&readfds);
+               timeout.tv_sec=0;
+               timeout.tv_usec=0;
+
+               if (select(PtyRDFD+1,&readfds,NULL/*writefds*/,NULL/*exceptfds*/,&timeout)) {
 
                        /* Check if the program has closed */
                        /* Return to command mode */
                        /* Note that the call will still be in progress, */
                        /* as with a normal modem (I think) */
 
-                       if (ufds.revents!=POLLIN) { 
+                       if (!FD_ISSET(PtyRDFD,&readfds)) { 
                                CommandMode=true;
                                /* Set the call passup back to the at emulator */
                                GSM->DialData(NULL,-1,&ATEM_CallPassup);
@@ -137,7 +148,7 @@ int DP_CallBack(RLP_UserInds ind, u8 *buffer, int length)
                        return temp;
                }
                return 0;
-               break;
+               break;
 
        default: