fixed some socket methods

This commit is contained in:
hyunghwan.chung 2017-12-28 17:45:55 +00:00
parent 6bf073cb0e
commit e39dd6027e
2 changed files with 24 additions and 33 deletions

View File

@ -46,14 +46,14 @@ extend Socket
## but ignore it here. ## but ignore it here.
if (self.insem notNil) if (self.insem notNil)
{ {
System unsignal: self.insem. System unsignal: self.insem;
System removeAsyncSemaphore: self.insem. removeAsyncSemaphore: self.insem.
self.insem := nil. self.insem := nil.
}. }.
if (self.outsem notNil) if (self.outsem notNil)
{ {
System unsignal: self.outsem. System unsignal: self.outsem;
System removeAsyncSemaphore: self.outsem. removeAsyncSemaphore: self.outsem.
self.outsem := nil. self.outsem := nil.
}. }.
@ -70,11 +70,11 @@ extend Socket
s2 := Semaphore new. s2 := Semaphore new.
sa := [:sem | sa := [:sem |
System unsignal: s1.
System unsignal: s2.
'UNSIGNALLLING ...........' dump. 'UNSIGNALLLING ...........' dump.
System removeAsyncSemaphore: s1. System unsignal: s1;
System removeAsyncSemaphore: s2. unsignal: s2;
removeAsyncSemaphore: s1;
removeAsyncSemaphore: s2.
'FINALIZING CONNECT' dump. 'FINALIZING CONNECT' dump.
self endConnect. self endConnect.
@ -85,10 +85,10 @@ extend Socket
s2 signalAction: sa. s2 signalAction: sa.
[ [
System signal: s1 onOutput: self.handle. System signal: s1 onOutput: self.handle;
System signal: s2 afterSecs: 10. signal: s2 afterSecs: 10;
System addAsyncSemaphore: s1. addAsyncSemaphore: s1;
System addAsyncSemaphore: s2. addAsyncSemaphore: s2.
self _connect(1, 2, 3). self _connect(1, 2, 3).
] ifCurtailed: [ ] ifCurtailed: [
## rollback ## rollback
@ -102,13 +102,10 @@ extend Socket
{ {
self.insem := Semaphore new. self.insem := Semaphore new.
self.insem signalAction: [:sem | self.inputAction value: self value: true]. self.insem signalAction: [:sem | self.inputAction value: self value: true].
System addAsyncSemaphore: self.insem;
}.
System signal: self.insem onInput: self.handle. System signal: self.insem onInput: self.handle.
System addAsyncSemaphore: self.insem.
}
else
{
self.insem signalAction: [:sem | self.inputAction value: self value: true].
}
###s2 := Semaphore new. ###s2 := Semaphore new.
###s2 signalAction: [:sem | inputActionBlock value: self value: false]. ###s2 signalAction: [:sem | inputActionBlock value: self value: false].
@ -117,8 +114,7 @@ extend Socket
method unwatchInput method unwatchInput
{ {
System unsignal: self.insem. if (self.insem notNil) { System unsignal: self.insem }.
System removeAsyncSemaphore: self.insem.
} }
method watchOutput method watchOutput
@ -127,19 +123,15 @@ extend Socket
{ {
self.outsem := Semaphore new. self.outsem := Semaphore new.
self.outsem signalAction: [:sem | self.outputAction value: self value: true]. self.outsem signalAction: [:sem | self.outputAction value: self value: true].
System signal: self.outsem onOutput: self.handle.
System addAsyncSemaphore: self.outsem. System addAsyncSemaphore: self.outsem.
} }.
else
{ System signal: self.outsem onOutput: self.handle.
self.outsem signalAction: [:sem | self.outputAction value: self value: true].
}
} }
method unwatchOutput method unwatchOutput
{ {
System unsignal: self.outsem. if (self.outsem notNil) { System unsignal: self.outsem }.
System removeAsyncSemaphore: self.outsem.
} }
} }
@ -169,7 +161,7 @@ class MyObject(Object)
outact := [:sck :state | outact := [:sck :state |
if (state) if (state)
{ {
sck writeBytes: #[ $h, $e, $l, $l, $o, 10 ]. sck writeBytes: #[ $h, $e, $l, $l, $o, C'\n' ].
} }
else else
@ -181,7 +173,7 @@ class MyObject(Object)
if (state) if (state)
{ {
'CONNECTED NOW.............' dump. 'CONNECTED NOW.............' dump.
s writeBytes: #[ $h $e $l $l $o ]. s writeBytes: #[ $h, $e, $l, $l, $o, C'\n' ].
s watchInput. s watchInput.
s watchOutput. s watchOutput.
@ -202,7 +194,6 @@ class MyObject(Object)
while (true) while (true)
{ {
System handleAsyncEvent. System handleAsyncEvent.
}. }.
s close dump. s close dump.

View File

@ -1883,7 +1883,7 @@ retry:
break; break;
case '"': case '"':
/* if QSE_PRAGMA_QC is set, this part should never be reached */ /* if MOO_PRAGMA_QC is set, this part should never be reached */
MOO_ASSERT (moo, !(moo->c->pragma_flags & MOO_PRAGMA_QC)); MOO_ASSERT (moo, !(moo->c->pragma_flags & MOO_PRAGMA_QC));
if (get_string(moo, '"', '\\', 0, 0) <= -1) return -1; if (get_string(moo, '"', '\\', 0, 0) <= -1) return -1;
break; break;