fixed log mask parsing in main.c.
touched up error handling a little bit
This commit is contained in:
parent
9f27e27d25
commit
edba0207fb
@ -44,13 +44,13 @@ extend Socket
|
||||
{
|
||||
## this primitive method may return failure.
|
||||
## but ignore it here.
|
||||
if (self.insem)
|
||||
if (self.insem notNil)
|
||||
{
|
||||
System unsignal: self.insem.
|
||||
System removeAsyncSemaphore: self.insem.
|
||||
self.insem := nil.
|
||||
}.
|
||||
if (self.outsem)
|
||||
if (self.outsem notNil)
|
||||
{
|
||||
System unsignal: self.outsem.
|
||||
System removeAsyncSemaphore: self.outsem.
|
||||
@ -158,15 +158,18 @@ class MyObject(Object)
|
||||
if (n == 0)
|
||||
{
|
||||
sck close.
|
||||
}.
|
||||
}
|
||||
else
|
||||
{
|
||||
(n asString & ' bytes read') dump.
|
||||
data dump.
|
||||
}.
|
||||
].
|
||||
|
||||
outact := [:sck :state |
|
||||
if (state)
|
||||
{
|
||||
sck writeBytes: #[ $h, $e, $l, $l, $o ].
|
||||
sck writeBytes: #[ $h, $e, $l, $l, $o, 10 ].
|
||||
|
||||
}
|
||||
else
|
||||
@ -178,7 +181,6 @@ class MyObject(Object)
|
||||
if (state)
|
||||
{
|
||||
'CONNECTED NOW.............' dump.
|
||||
##s onOutputDo: outact.
|
||||
s writeBytes: #[ $h $e $l $l $o ].
|
||||
|
||||
s watchInput.
|
||||
|
@ -29,7 +29,7 @@ class MyObject(Object)
|
||||
'resource temporarily unavailable'
|
||||
'bad system handle'
|
||||
|
||||
'data too large'
|
||||
'*** undefined error ***'
|
||||
'message receiver error'
|
||||
'message sending error'
|
||||
'wrong number of arguments'
|
||||
@ -37,8 +37,8 @@ class MyObject(Object)
|
||||
'byte-code full'
|
||||
'dictionary full'
|
||||
'processor full'
|
||||
'semaphore heap full'
|
||||
'semaphore list full'
|
||||
'too many semaphores'
|
||||
'*** undefined error ***'
|
||||
'divide by zero'
|
||||
'I/O error'
|
||||
'encoding conversion error'
|
||||
|
@ -57,7 +57,7 @@ static moo_ooch_t errstr_23[] = {'r','a','n','g','e',' ','e','r','r','o','r','\0
|
||||
static moo_ooch_t errstr_24[] = {'b','y','t','e','-','c','o','d','e',' ','f','u','l','l','\0'};
|
||||
static moo_ooch_t errstr_25[] = {'d','i','c','t','i','o','n','a','r','y',' ','f','u','l','l','\0'};
|
||||
static moo_ooch_t errstr_26[] = {'p','r','o','c','e','s','s','o','r',' ','f','u','l','l','\0'};
|
||||
static moo_ooch_t errstr_27[] = {'s','e','m','a','p','h','o','r','e',' ','h','e','a','p',' ','f','u','l','l','\0'};
|
||||
static moo_ooch_t errstr_27[] = {'t','o','o',' ','m','a','n','y',' ','s','e','m','a','p','h','o','r','e','s','\0'};
|
||||
static moo_ooch_t errstr_28[] = {'s','e','m','a','p','h','o','r','e',' ','l','i','s','t',' ','f','u','l','l','\0'};
|
||||
static moo_ooch_t errstr_29[] = {'d','i','v','i','d','e',' ','b','y',' ','z','e','r','o','\0'};
|
||||
static moo_ooch_t errstr_30[] = {'I','/','O',' ','e','r','r','o','r','\0'};
|
||||
@ -313,7 +313,7 @@ void moo_seterrwithsyserr (moo_t* moo, int syserr)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* ASSERTION FAILURE HANDLER
|
||||
* ASSERTION FAILURE HANDLERsemaphore heap full
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
void moo_assertfailed (moo_t* moo, const moo_bch_t* expr, const moo_bch_t* file, moo_oow_t line)
|
||||
|
@ -57,6 +57,7 @@ static MOO_INLINE const char* proc_state_to_string (int state)
|
||||
#define SEM_LIST_MAX (SEM_LIST_INC * 1000)
|
||||
#define SEM_HEAP_MAX (SEM_HEAP_INC * 1000)
|
||||
#define SEM_IO_TUPLE_MAX (SEM_IO_TUPLE_INC * 1000)
|
||||
#define SEM_IO_MAP_ALIGN 1024 /* this must a power of 2 */
|
||||
|
||||
#define SEM_HEAP_PARENT(x) (((x) - 1) / 2)
|
||||
#define SEM_HEAP_LEFT(x) ((x) * 2 + 1)
|
||||
@ -740,7 +741,7 @@ static int async_signal_semaphore (moo_t* moo, moo_oop_semaphore_t sem)
|
||||
{
|
||||
if (moo->sem_list_count >= SEM_LIST_MAX)
|
||||
{
|
||||
moo_seterrnum (moo, MOO_ESLFULL);
|
||||
moo_seterrnum (moo, MOO_ESEMFLOOD, "too many semaphores in the semaphore list");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1029,7 +1030,7 @@ static int add_to_sem_heap (moo_t* moo, moo_oop_semaphore_t sem)
|
||||
|
||||
if (moo->sem_heap_count >= SEM_HEAP_MAX)
|
||||
{
|
||||
moo_seterrnum (moo, MOO_ESHFULL);
|
||||
moo_seterrbfmt(moo, MOO_ESEMFLOOD, "too many semaphores in the semaphore heap");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1126,13 +1127,13 @@ static int add_to_sem_io (moo_t* moo, moo_oop_semaphore_t sem, moo_ooi_t io_hand
|
||||
|
||||
/* TODO: specify the maximum io_handle supported and check it here instead of just relying on memory allocation success/failure? */
|
||||
|
||||
new_capa = MOO_ALIGN_POW2 (io_handle + 1, 1024);
|
||||
new_capa = MOO_ALIGN_POW2(io_handle + 1, SEM_IO_MAP_ALIGN);
|
||||
|
||||
tmp = moo_reallocmem (moo, moo->sem_io_map, MOO_SIZEOF(*tmp) * new_capa);
|
||||
if (!tmp)
|
||||
{
|
||||
moo_copyoocstr (moo->errmsg.buf2, MOO_COUNTOF(moo->errmsg.buf2), moo->errmsg.buf);
|
||||
moo_seterrbfmt (moo, MOO_EINVAL, "handle %zd out of supported range - %js", moo->errmsg.buf2);
|
||||
moo_seterrbfmt (moo, moo->errnum, "handle %zd out of supported range - %js", moo->errmsg.buf2);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1148,7 +1149,7 @@ static int add_to_sem_io (moo_t* moo, moo_oop_semaphore_t sem, moo_ooi_t io_hand
|
||||
/* this handle is not in any tuples. add it to a new tuple */
|
||||
if (moo->sem_io_tuple_count >= SEM_IO_TUPLE_MAX)
|
||||
{
|
||||
moo_seterrbfmt (moo, MOO_ESHFULL, "too many IO semaphore tuples"); /* TODO: change error code */
|
||||
moo_seterrbfmt (moo, MOO_ESEMFLOOD, "too many IO semaphore tuples");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -725,7 +725,8 @@ static void log_write (moo_t* moo, moo_oow_t mask, const moo_ooch_t* msg, moo_oo
|
||||
xtn_t* xtn = moo_getxtn(moo);
|
||||
int logfd;
|
||||
|
||||
if (!(xtn->logmask & mask)) return;
|
||||
if (!(xtn->logmask & mask & ~MOO_LOG_ALL_LEVELS)) return; /* check log types */
|
||||
if (!(xtn->logmask & mask & ~MOO_LOG_ALL_TYPES)) return; /* check log levels */
|
||||
|
||||
if (mask & MOO_LOG_STDOUT) logfd = 1;
|
||||
else if (mask & MOO_LOG_STDERR) logfd = 2;
|
||||
@ -2029,10 +2030,23 @@ static int handle_logopt (moo_t* moo, const moo_bch_t* str)
|
||||
else if (moo_compbcstr(flt, "ic") == 0) xtn->logmask |= MOO_LOG_IC;
|
||||
else if (moo_compbcstr(flt, "primitive") == 0) xtn->logmask |= MOO_LOG_PRIMITIVE;
|
||||
|
||||
else if (moo_compbcstr(flt, "fatal") == 0) xtn->logmask |= MOO_LOG_FATAL;
|
||||
else if (moo_compbcstr(flt, "error") == 0) xtn->logmask |= MOO_LOG_ERROR;
|
||||
else if (moo_compbcstr(flt, "warn") == 0) xtn->logmask |= MOO_LOG_WARN;
|
||||
else if (moo_compbcstr(flt, "info") == 0) xtn->logmask |= MOO_LOG_INFO;
|
||||
else if (moo_compbcstr(flt, "debug") == 0) xtn->logmask |= MOO_LOG_DEBUG;
|
||||
|
||||
else if (moo_compbcstr(flt, "fatal+") == 0) xtn->logmask |= MOO_LOG_FATAL;
|
||||
else if (moo_compbcstr(flt, "error+") == 0) xtn->logmask |= MOO_LOG_FATAL | MOO_LOG_ERROR;
|
||||
else if (moo_compbcstr(flt, "warn+") == 0) xtn->logmask |= MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN;
|
||||
else if (moo_compbcstr(flt, "info+") == 0) xtn->logmask |= MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN | MOO_LOG_INFO;
|
||||
else if (moo_compbcstr(flt, "debug+") == 0) xtn->logmask |= MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN | MOO_LOG_INFO | MOO_LOG_DEBUG;
|
||||
}
|
||||
while (cm);
|
||||
|
||||
xtn->logmask |= MOO_LOG_ALL_LEVELS; /* TODO: parse levels also */
|
||||
|
||||
if (!(xtn->logmask & MOO_LOG_ALL_TYPES)) xtn->logmask |= MOO_LOG_ALL_TYPES; /* no types specified. force to all types */
|
||||
if (!(xtn->logmask & MOO_LOG_ALL_LEVELS)) xtn->logmask |= MOO_LOG_ALL_LEVELS; /* no levels specified. force to all levels */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ enum moo_errnum_t
|
||||
MOO_EAGAIN,
|
||||
MOO_EBADHND,
|
||||
|
||||
MOO_ENOAVAIL, /**< data not available*/
|
||||
MOO_EXXXXX1, /**< **** not used ****/
|
||||
MOO_EMSGRCV, /**< mesasge receiver error */
|
||||
MOO_EMSGSND, /**< message sending error. even doesNotUnderstand: is not found */
|
||||
MOO_ENUMARGS, /**< wrong number of arguments */
|
||||
@ -75,8 +75,8 @@ enum moo_errnum_t
|
||||
MOO_EBCFULL, /**< byte-code full */
|
||||
MOO_EDFULL, /**< dictionary full */
|
||||
MOO_EPFULL, /**< processor full */
|
||||
MOO_ESHFULL, /**< semaphore heap full */
|
||||
MOO_ESLFULL, /**< semaphore list full */
|
||||
MOO_ESEMFLOOD,/**< too many semaphores */
|
||||
MOO_EXXXXX2, /**< **** not used ***** */
|
||||
MOO_EDIVBY0, /**< divide by zero */
|
||||
MOO_EIOERR, /**< I/O error */
|
||||
MOO_EECERR, /**< encoding conversion error */
|
||||
@ -990,11 +990,6 @@ struct moo_vmprim_t
|
||||
|
||||
typedef struct moo_vmprim_t moo_vmprim_t;
|
||||
|
||||
/* =========================================================================
|
||||
* IO MANIPULATION
|
||||
* ========================================================================= */
|
||||
|
||||
/* TODO: MOVE moo_ioimpl_t HERE */
|
||||
|
||||
/* =========================================================================
|
||||
* CALLBACK MANIPULATION
|
||||
|
Loading…
Reference in New Issue
Block a user