[kaffe] unix-pthreads accept timeout

Mathieu Dube mdube@8d.com
Tue, 6 Aug 2002 14:50:38 -0400


--------------Boundary-00=_E0RFWE6W1W2AT19KHIFS
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

Hi,
	Im not sure this was a bug or just that Im doing something wrong but in 
kaffe/kaffevm/systems/unix-pthreads/syscalls.c the function jthreadedAccept 
assumes that the fd is O_NONBLOCK. If the fd is blocking the function will 
not go passed the accept syscall and thus never reach the BREAK_IF_LATE macro.
	So what I did is to check if the socket is blocking or not, if its not I let 
it go through the original loop if its blocking I put the fd in a select and 
use the timeout in a timeval struct.
	I attached my modified syscalls.c to this mail

Later
-Mat
-- 
Mathieu Dube -- mdube@8d.com
8D Technologies Inc.
http://www.8d.com

--------------Boundary-00=_E0RFWE6W1W2AT19KHIFS
Content-Type: text/x-c;
  charset="iso-8859-1";
  name="syscalls.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="syscalls.c"

LyoKICogc3lzY2FsbHMuYwogKgogKiBDb3B5cmlnaHQgKGMpIDE5OTYsIDE5OTcKICogICAgICBU
cmFuc3ZpcnR1YWwgVGVjaG5vbG9naWVzLCBJbmMuICBBbGwgcmlnaHRzIHJlc2VydmVkLgogKgog
KiBTZWUgdGhlIGZpbGUgImxpY2Vuc2UudGVybXMiIGZvciBpbmZvcm1hdGlvbiBvbiB1c2FnZSBh
bmQgcmVkaXN0cmlidXRpb24KICogb2YgdGhpcyBmaWxlLgogKi8KCiNpbmNsdWRlICJjb25maWcu
aCIKI2luY2x1ZGUgImRlYnVnLmgiCiNpbmNsdWRlICJjb25maWctc3RkLmgiCiNpbmNsdWRlICJj
b25maWctbWVtLmgiCiNpbmNsdWRlICJjb25maWctaW8uaCIKI2luY2x1ZGUgImNvbmZpZy1zaWdu
YWwuaCIKI2luY2x1ZGUgImNvbmZpZy1uZXQuaCIKI2luY2x1ZGUgImd0eXBlcy5oIgojaW5jbHVk
ZSAianN5c2NhbGwuaCI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AgICAgICAgICAgIHIgPSBlcnJubzsKICAgICAgICB9IGVs
c2UgewogICAgICAgICAgICAgICAgKm91dCA9IHI7CiAgICAgICAgICAgICAgICByID0gMDsKICAg
ICAgICB9CiAgICAgICAgcmV0dXJuIChyKTsKfQoKaW50Cmp0aHJlYWRlZE9wZW4oY29uc3QgY2hh
ciogcGF0aCwgaW50IGZsYWdzLCBpbnQgbW9kZSwgaW50ICpvdXQpCnsKICAgICAgICBpbnQgcjsK
CiAgICAgICAgLyogQ3lnbnVzIFdpbk5UIHJlcXVpcmVzIHRoaXMgKi8KICAgICAgICByID0gb3Bl
bihwYXRoLCBmbGFnc3xPX0JJTkFSWSwgbW9kZSk7CiAgICAgICAgaWYgKHIgPT0gLTEpIHsKICAg
ICAgICAgICAgICAgIHIgPSBlcnJubzsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAg
Km91dCA9IHI7CiAgICAgICAgICAgICAgICByID0gMDsKICAgICAgICB9CiAgICAgICAgcmV0dXJu
IChyKTsKfQoKc3RhdGljIGludApqdGhyZWFkZWRDbG9zZShpbnQgZmQpCnsKCWludCByYyA9IDA7
CgoJaWYgKGNsb3NlKGZkKSA9PSAtMSkgewoJCXJjID0gZXJybm87Cgl9CglyZXR1cm4gKHJjKTsK
fQoKc3RhdGljIGludApqdGhyZWFkZWRMaXN0ZW4oaW50IGZkLCBpbnQgbCkKewoJaW50IHJjID0g
MDsKCglpZiAobGlzdGVuKGZkLCBsKSA9PSAtMSkgewoJCXJjID0gZXJybm87Cgl9CglyZXR1cm4g
KHJjKTsKfQoKc3RhdGljIGludApqdGhyZWFkZWRLaWxsKGludCBwaWQsIGludCBzaWcpCnsKCWlu
dCByYyA9IDA7CgoJaWYgKGtpbGwocGlkLCBzaWcpID09IC0xKSB7CgkJcmMgPSBlcnJubzsKCX0K
CXJldHVybiAocmMpOwp9CgpzdGF0aWMgaW50Cmp0aHJlYWRlZEJpbmQoaW50IGZkLCBzdHJ1Y3Qg
c29ja2FkZHI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GhlIGludGVybmFsIGp0aHJlYWQgc3lzdGVtLgogKi8KU3lzdGVtQ2FsbEludGVyZmFjZSBL
YWZmZV9TeXN0ZW1DYWxsSW50ZXJmYWNlID0gewogICAgICAgIGp0aHJlYWRlZE9wZW4sCiAgICAg
ICAganRocmVhZGVkUmVhZCwJCiAgICAgICAganRocmVhZGVkV3JpdGUsIAogICAgICAgIGp0aHJl
YWRlZExTZWVrLAogICAgICAgIGp0aHJlYWRlZENsb3NlLAogICAgICAgIGp0aHJlYWRlZEZTdGF0
LAogICAgICAgIGp0aHJlYWRlZFN0YXQsCiAgICAgICAganRocmVhZGVkTWtkaXIsCiAgICAgICAg
anRocmVhZGVkUm1kaXIsCiAgICAgICAganRocmVhZGVkUmVuYW1lLAogICAgICAgIGp0aHJlYWRl
ZFJlbW92ZSwKICAgICAgICBqdGhyZWFkZWRTb2NrZXQsCiAgICAgICAganRocmVhZGVkQ29ubmVj
dCwKICAgICAgICBqdGhyZWFkZWRCaW5kLAogICAgICAgIGp0aHJlYWRlZExpc3RlbiwKICAgICAg
ICBqdGhyZWFkZWRBY2NlcHQsIAogICAgICAgIGp0aHJlYWRlZFRpbWVkUmVhZCwJCiAgICAgICAg
anRocmVhZGVkUmVjdmZyb20sCiAgICAgICAganRocmVhZGVkV3JpdGUsIAogICAgICAgIGp0aHJl
YWRlZFNlbmR0bywJCiAgICAgICAganRocmVhZGVkU2V0U29ja09wdCwJCiAgICAgICAganRocmVh
ZGVkR2V0U29ja09wdCwKICAgICAgICBqdGhyZWFkZWRHZXRTb2NrTmFtZSwgCiAgICAgICAganRo
cmVhZGVkR2V0UGVlck5hbWUsIAogICAgICAgIGp0aHJlYWRlZENsb3NlLAogICAgICAgIGp0aHJl
YWRlZEdldEhvc3RCeU5hbWUsCiAgICAgICAganRocmVhZGVkR2V0SG9zdEJ5QWRkciwKICAgICAg
ICBqdGhyZWFkZWRTZWxlY3QsCQogICAgICAgIGp0aHJlYWRlZEZvcmtFeGVjLAogICAgICAgIGp0
aHJlYWRlZFdhaXRwaWQsCiAgICAgICAganRocmVhZGVkS2lsbAp9Owo=

--------------Boundary-00=_E0RFWE6W1W2AT19KHIFS--