From 2255425b3f6b757df81b3b808298804f7050ad4a Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Sun, 14 Jan 2018 15:11:53 +0000 Subject: [PATCH] fixed a bug in socket accept --- moo/kernel/Socket.moo | 8 +++++--- moo/kernel/System.moo | 5 +++++ moo/mod/sck.c | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/moo/kernel/Socket.moo b/moo/kernel/Socket.moo index 8a818ff..c4210ee 100644 --- a/moo/kernel/Socket.moo +++ b/moo/kernel/Socket.moo @@ -242,7 +242,7 @@ class(#pointer) Y(X) class Socket(Object) from 'sck' { - var handle := -1. + var(#get) handle := -1. var insem, outsem. var(#get,#set) inputAction, outputAction. @@ -491,9 +491,11 @@ error -> exception newaddr := SocketAddress new. newsck := sck accept: newaddr. -System log: 'new connection - '; logNl: newaddr. + + System log: 'new connection - '; log: newaddr; log: ' '; log: (newsck handle); logNl. + newsck inputAction: inact; outputAction: outact. - newsck watchInput; watchOuptut. + newsck watchInput; watchOutput. ]. [ diff --git a/moo/kernel/System.moo b/moo/kernel/System.moo index 7295b29..4f638f9 100644 --- a/moo/kernel/System.moo +++ b/moo/kernel/System.moo @@ -210,6 +210,11 @@ TODO: how to pass all variadic arguments to another variadic methods??? ^self atLevel: System.Log.INFO log: message and: message2. } + method(#class) logNl + { + ^self atLevel: System.Log.INFO log: S'\n'. + } + method(#class) logNl: message { ^self atLevel: System.Log.INFO logNl: message. diff --git a/moo/mod/sck.c b/moo/mod/sck.c index 1342fea..6e132b0 100644 --- a/moo/mod/sck.c +++ b/moo/mod/sck.c @@ -192,7 +192,7 @@ static moo_pfrc_t pf_accept_socket (moo_t* moo, moo_ooi_t nargs) } newsck->handle = MOO_SMOOI_TO_OOP(newfd); - MOO_STACK_SETRETTORCV (moo, nargs); + MOO_STACK_SETRET (moo, nargs, (moo_oop_t)newsck); return MOO_PF_SUCCESS; }