[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Ayttm-commits] CVS: ayttm/modules/msn2/libmsn2 msn_bittybits.C,1.8,1.9
From: |
Colin Leroy <address@hidden> |
Subject: |
[Ayttm-commits] CVS: ayttm/modules/msn2/libmsn2 msn_bittybits.C,1.8,1.9 |
Date: |
Tue, 25 Mar 2003 07:51:34 -0500 |
Update of /cvsroot/ayttm/ayttm/modules/msn2/libmsn2
In directory subversions:/tmp/cvs-serv19917/modules/msn2/libmsn2
Modified Files:
msn_bittybits.C
Log Message:
fix MSN hanging with long messages
Index: msn_bittybits.C
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/msn2/libmsn2/msn_bittybits.C,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- msn_bittybits.C 23 Mar 2003 23:05:35 -0000 1.8
+++ msn_bittybits.C 25 Mar 2003 12:51:31 -0000 1.9
@@ -6,6 +6,10 @@
#include <unistd.h>
#include <ctype.h>
+#ifndef __MINGW32__
+#include <sys/poll.h>
+#endif
+
#include "msn_core.h"
#include "msn_interface.h"
#include "msn_bittybits.h"
@@ -18,13 +22,20 @@
char ** retval;
char c;
int pos=0, numspaces=0;
+ int should_terminate=0;
#ifndef __MINGW32__
+ struct pollfd pfd;
struct timespec delay;
+
+ pfd.fd=sock;
+ pfd.events=POLLIN;
+
delay.tv_sec = 0;
delay.tv_nsec = 10000000;
#endif
- while(1)
+ do
{
+ should_terminate = 0;
if(read(sock, &c, 1)<1)
{
if (errno == EAGAIN) {
@@ -33,7 +44,13 @@
for (int i=0; i<10000000;i++)
j=i;
#else
- nanosleep(&delay, NULL);
+ printf("EAGAIN, sleeping\n");
+ if(poll(&pfd,1,1000)==0) {
+ should_terminate = 1;
+ break;
+ } else
+ continue;
+
#endif
continue;
} else {
@@ -48,8 +65,25 @@
if(c==' ') { numspaces++; }
buf[pos]=c;
pos++;
+#ifndef __WINGW32__
+ if(poll(&pfd,1,0)==0) {
+ printf("nothing available sleeping\n");
+ should_terminate=1;
+ poll(&pfd,1,1000);
+ }
+#endif
}
-
+#ifndef __WINGW32__
+ while(poll(&pfd, 1, 0)==1);
+#else
+ while (1);
+#endif
+ if (should_terminate) {
+ printf("terminating short string\n");
+ numspaces++; buf[pos]='\0';
+ pos++;
+ }
+
if(numspaces==0) { printf("What the..?\n"); return NULL; }
retval=new char * [numspaces];
- [Ayttm-commits] CVS: ayttm/modules/msn2/libmsn2 msn_bittybits.C,1.8,1.9,
Colin Leroy <address@hidden> <=
- Prev by Date:
[Ayttm-commits] CVS: ayttm/src/gtk about.c,1.3,1.4
- Next by Date:
[Ayttm-commits] CVS: ayttm ChangeLog,1.414,1.415 configure.in,1.409,1.410
- Previous by thread:
[Ayttm-commits] CVS: ayttm/src/gtk about.c,1.3,1.4
- Next by thread:
Re: [Ayttm-commits] CVS: ayttm/modules/msn2/libmsn2 msn_bittybits.C,1.8,1.9
- Index(es):