return -1;
}
+#ifdef TASK
+int CALL12(___Socket______nativeBindFD____I, int ___fd___, struct ___Socket___ * ___this___, int ___fd___) {
+ if (RuntimeHashcontainskey(fdtoobject, ___fd___))
+ RuntimeHashremovekey(fdtoobject, ___fd___);
+ RuntimeHashadd(fdtoobject, ___fd___, (int) VAR(___this___));
+ addreadfd(___fd___);
+}
+#endif
+
int CALL12(___Socket______nativeBind_____AR_B_I, int ___port___, struct ArrayObject * ___address___, int ___port___) {
int fd;
#endif
}
+#ifdef MAC
+ if (setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &n, sizeof (n)) < 0) {
+ perror("socket");
+ exit(-1);
+ }
+#endif
+
#ifdef TASK
fcntl(fd, F_SETFD, 1);
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL)|O_NONBLOCK);
return newfd;
}
-void CALL02(___Socket______nativeWrite_____AR_B, struct ___Socket___ * ___this___, struct ArrayObject * ___b___) {
+void CALL24(___Socket______nativeWrite_____AR_B_I_I, int offset, int length, struct ___Socket___ * ___this___, struct ArrayObject * ___b___, int offset, int length) {
int fd=VAR(___this___)->___fd___;
- int length=VAR(___b___)->___length___;
- char * charstr=((char *)& VAR(___b___)->___length___)+sizeof(int);
+ char * charstr=((char *)& VAR(___b___)->___length___)+sizeof(int)+offset;
while(1) {
- int bytewritten=write(fd, charstr, length);
- if (bytewritten==-1&&errno==EAGAIN)
- continue;
+ int offset=0;
+ int bytewritten;
+ while(length>0) {
+ bytewritten=write(fd, &charstr[offset], length);
+ if (bytewritten==-1&&errno!=EAGAIN)
+ break;
+ length-=bytewritten;
+ offset+=bytewritten;
+ }
- if (bytewritten!=length) {
+ if (length!=0) {
perror("ERROR IN NATIVEWRITE");
+ printf("error=%d remaining bytes %d\n",errno, length);
}
break;
}
struct listitem *tmp=stopforgc((struct garbagelist *)___params___);
#endif
#endif
- int byteread=read(fd, charstr, length);
+ int byteread=-1;
+
+ // printf("Doing read on %d\n",fd);
+ do {
+ byteread=read(fd, charstr, length);
+ } while(byteread==-1&&errno==EINTR);
#ifdef THREADS
#ifdef PRECISE_GC
restartaftergc(tmp);
#endif
#endif
-
+
{
int i;
for(i=0;i<byteread;i++) {
if (byteread<0) {
printf("ERROR IN NATIVEREAD\n");
- return 0;
+ perror("");
}
#ifdef TASK
flagorand(VAR(___this___),0,0xFFFFFFFE);