[kaffe] unix-pthreads accept timeout

Mathieu Dube mdube@8d.com
Wed, 7 Aug 2002 10:13:37 -0400


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

Ok,
	I changed it. I also put a check to see if the timeout is 0 to pass NULL to 
select() and added a timeout*1000 since usecs and millisecs arent the same.
	My java programmer here seems to say it works.

Thanks
Later
-Mat

On Wednesday 07 August 2002 10:02, you wrote:
> > Plus jthreadedAccept as a timeout passed as an argument. It works
> > perfectly in the unix-jthreads version.
>
> Right, I wouldn't have implemented it there if it hadn't been
> needed.
>
> > > (On a more general note, the interface contract of the jsyscall stuff
> > > is that you don't pass in arbitrary or arbitrarily modded file
> > > descriptors, you pass the fds you get from jthreadedSocket/Open/Accept
> > > etc. A minimum of encapsulation doesn't hurt.)
> >
> > Do you mean that I should write a function that waits for the timeout
> > instead of having the select() code directly in the jthreadedAccept
> > function?
>
> Just remove the test whether it's nonblocking in your patch.
> Assume that it's a fd return from a jthreaded* function, which
> is blocking.  Other than that, select() might just work in
> pthreads.
>
> 	- Godmar

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

--------------Boundary-00=_PU8H4PTOKPVLE8BW8ECI
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
aCIKI2luY2x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wMEwpKTsKfQoKLyoKICogVGhyZWFkZWQgc29ja2V0IGNyZWF0ZS4KICovCmludApq
dGhyZWFkZWRTb2NrZXQoaW50IGFmLCBpbnQgdHlwZSwgaW50IHByb3RvLCBpbnQgKm91dCkKewog
ICAgICAgIGludCByOwoKICAgICAgICByID0gc29ja2V0KGFmLCB0eXBlLCBwcm90byk7CiAgICAg
ICAgaWYgKHIgPT0gLTEpIHsKICAgICAgICAgICAgICAgIHIgPSBlcnJubzsKICAgICAgICB9IGVs
c2UgewogICAgICAgICAgICAgICAgKm91dCA9IHI7CiAgICAgICAgICAgICAgICByID0gMDsKICAg
ICAgICB9CiAgICAgICAgcmV0dXJuIChyKTsKfQoKaW50Cmp0aHJlYWRlZE9wZW4oY29uc3QgY2hh
ciogcGF0aCwgaW50IGZsYWdzLCBpbnQgbW9kZSwgaW50ICpvdXQpCnsKICAgICAgICBpbnQgcjsK
CiAgICAgICAgLyogQ3lnbnVzIFdpbk5UIHJlcXVpcmVzIHRoaXMgKi8KICAgICAgICByID0gb3Bl
bihwYXRoLCBmbGFnc3xPX0JJTkFSWSwgbW9kZSk7CiAgICAgICAgaWYgKHIgPT0gLTEpIHsKICAg
ICAgICAgICAgICAgIHIgPSBlcnJubzsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAg
Km91dCA9IHI7CiAgICAgICAgICAgICAgICByID0gMDsKICAgICAgICB9CiAgICAgICAgcmV0dXJu
IChyKTsKfQoKc3RhdGljIGludApqdGhyZWFkZWRDbG9zZShpbnQgZmQpCnsKCWludCByYyA9IDA7
CgoJaWYgKGNsb3NlKGZkKSA9PSAtMSkgewoJCXJjID0gZXJybm87Cgl9CglyZXR1cm4gKHJjKTsK
fQoKc3RhdGljIGludApqdGhyZWFkZWRMaXN0ZW4oaW50IGZkLCBpbnQgbCkKewoJaW50IHJjID0g
MDsKCglpZiAobGlzdGVuKGZkLCBsKSA9PSAtMSkgewoJCXJjID0gZXJybm87Cgl9CglyZXR1cm4g
KHJjK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AgICAgIGp0aHJlYWRlZEZTdGF0LAogICAgICAg
IGp0aHJlYWRlZFN0YXQsCiAgICAgICAganRocmVhZGVkTWtkaXIsCiAgICAgICAganRocmVhZGVk
Um1kaXIsCiAgICAgICAganRocmVhZGVkUmVuYW1lLAogICAgICAgIGp0aHJlYWRlZFJlbW92ZSwK
ICAgICAgICBqdGhyZWFkZWRTb2NrZXQsCiAgICAgICAganRocmVhZGVkQ29ubmVjdCwKICAgICAg
ICBqdGhyZWFkZWRCaW5kLAogICAgICAgIGp0aHJlYWRlZExpc3RlbiwKICAgICAgICBqdGhyZWFk
ZWRBY2NlcHQsIAogICAgICAgIGp0aHJlYWRlZFRpbWVkUmVhZCwJCiAgICAgICAganRocmVhZGVk
UmVjdmZyb20sCiAgICAgICAganRocmVhZGVkV3JpdGUsIAogICAgICAgIGp0aHJlYWRlZFNlbmR0
bywJCiAgICAgICAganRocmVhZGVkU2V0U29ja09wdCwJCiAgICAgICAganRocmVhZGVkR2V0U29j
a09wdCwKICAgICAgICBqdGhyZWFkZWRHZXRTb2NrTmFtZSwgCiAgICAgICAganRocmVhZGVkR2V0
UGVlck5hbWUsIAogICAgICAgIGp0aHJlYWRlZENsb3NlLAogICAgICAgIGp0aHJlYWRlZEdldEhv
c3RCeU5hbWUsCiAgICAgICAganRocmVhZGVkR2V0SG9zdEJ5QWRkciwKICAgICAgICBqdGhyZWFk
ZWRTZWxlY3QsCQogICAgICAgIGp0aHJlYWRlZEZvcmtFeGVjLAogICAgICAgIGp0aHJlYWRlZFdh
aXRwaWQsCiAgICAgICAganRocmVhZGVkS2lsbAp9Owo=

--------------Boundary-00=_PU8H4PTOKPVLE8BW8ECI--