removed qse_syserr_to_errnum().

changed syserrstrb() and syserrstru() to return the converted error number from the system error code
This commit is contained in:
hyunghwan.chung 2018-11-02 05:51:22 +00:00
parent 4edebb2a45
commit 1a3a681e8d
6 changed files with 194 additions and 195 deletions

View File

@ -7740,8 +7740,7 @@ static int process_class_module_import (moo_t* moo)
return -1; return -1;
} }
if (TOKEN_NAME_LEN(moo) <= 0 || if (TOKEN_NAME_LEN(moo) <= 0 || TOKEN_NAME_LEN(moo) > MOO_MOD_NAME_LEN_MAX ||
TOKEN_NAME_LEN(moo) > MOO_MOD_NAME_LEN_MAX ||
moo_find_oochar(TOKEN_NAME_PTR(moo), TOKEN_NAME_LEN(moo), '-') ) moo_find_oochar(TOKEN_NAME_PTR(moo), TOKEN_NAME_LEN(moo), '-') )
{ {
/* check for a bad module name. /* check for a bad module name.

View File

@ -226,153 +226,6 @@ static const moo_ooch_t* synerr_to_errstr (moo_synerrnum_t errnum)
# include <errno.h> # include <errno.h>
#endif #endif
moo_errnum_t moo_syserr_to_errnum (int e)
{
#if 0
/* -------------------------------------- */
/* currently 'e' is expected to be 'errno'. it doesn't support GetLastError() on win32 or APIRET on os2 yet */
/* -------------------------------------- */
#if defined(__OS2__)
/* APIRET e */
switch (e)
{
case ERROR_NOT_ENOUGH_MEMORY: return MOO_ESYSMEM;
case ERROR_INVALID_PARAMETER:
case ERROR_INVALID_HANDLE:
case ERROR_INVALID_NAME: return MOO_EINVAL;
case ERROR_ACCESS_DENIED:
case ERROR_SHARING_VIOLATION: return MOO_EACCES;
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND: return MOO_ENOENT;
case ERROR_ALREADY_EXISTS: return MOO_EEXIST;
/*TODO: add more mappings */
default: return MOO_ESYSERR;
}
#elif defined(macintosh)
switch (e)
{
case notEnoughMemoryErr: return MOO_ESYSMEM;
case paramErr: return MOO_EINVAL;
case qErr: /* queue element not found during deletion */
case fnfErr: /* file not found */
case dirNFErr: /* direcotry not found */
case resNotFound: /* resource not found */
case resFNotFound: /* resource file not found */
case nbpNotFound: /* name not found on remove */
return MOO_ENOENT;
/*TODO: add more mappings */
default: return MOO_ESYSERR;
}
#else
switch (e)
{
case ENOMEM: return MOO_ESYSMEM;
case EINVAL: return MOO_EINVAL;
#if defined(EBUSY)
case EBUSY: return MOO_EBUSY;
#endif
case EACCES: return MOO_EACCES;
#if defined(EPERM)
case EPERM: return MOO_EPERM;
#endif
#if defined(ENOTDIR)
case ENOTDIR: return MOO_ENOTDIR;
#endif
case ENOENT: return MOO_ENOENT;
#if defined(EEXIST)
case EEXIST: return MOO_EEXIST;
#endif
#if defined(EINTR)
case EINTR: return MOO_EINTR;
#endif
#if defined(EPIPE)
case EPIPE: return MOO_EPIPE;
#endif
#if defined(EAGAIN) && defined(EWOULDBLOCK) && (EAGAIN != EWOULDBLOCK)
case EAGAIN:
case EWOULDBLOCK: return MOO_EAGAIN;
#elif defined(EAGAIN)
case EAGAIN: return MOO_EAGAIN;
#elif defined(EWOULDBLOCK)
case EWOULDBLOCK: return MOO_EAGAIN;
#endif
#if defined(EBADF)
case EBADF: return MOO_EBADHND;
#endif
#if defined(EIO)
case EIO: return MOO_EIOERR;
#endif
default: return MOO_ESYSERR;
}
#endif
#else
/* ------------------------------------------------------------------- */
switch (e)
{
case ENOMEM: return MOO_ESYSMEM;
case EINVAL: return MOO_EINVAL;
#if defined(EBUSY)
case EBUSY: return MOO_EBUSY;
#endif
case EACCES: return MOO_EACCES;
#if defined(EPERM)
case EPERM: return MOO_EPERM;
#endif
#if defined(ENOTDIR)
case ENOTDIR: return MOO_ENOTDIR;
#endif
case ENOENT: return MOO_ENOENT;
#if defined(EEXIST)
case EEXIST: return MOO_EEXIST;
#endif
#if defined(EINTR)
case EINTR: return MOO_EINTR;
#endif
#if defined(EPIPE)
case EPIPE: return MOO_EPIPE;
#endif
#if defined(EAGAIN) && defined(EWOULDBLOCK) && (EAGAIN != EWOULDBLOCK)
case EAGAIN:
case EWOULDBLOCK: return MOO_EAGAIN;
#elif defined(EAGAIN)
case EAGAIN: return MOO_EAGAIN;
#elif defined(EWOULDBLOCK)
case EWOULDBLOCK: return MOO_EAGAIN;
#endif
#if defined(EBADF)
case EBADF: return MOO_EBADHND;
#endif
#if defined(EIO)
case EIO: return MOO_EIOERR;
#endif
default: return MOO_ESYSERR;
}
/* ------------------------------------------------------------------- */
#endif
}
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
* ERROR NUMBER/MESSAGE HANDLING * ERROR NUMBER/MESSAGE HANDLING
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
@ -401,20 +254,22 @@ void moo_seterrnum (moo_t* moo, moo_errnum_t errnum)
moo->errmsg.len = 0; moo->errmsg.len = 0;
} }
void moo_seterrwithsyserr (moo_t* moo, int syserr) void moo_seterrwithsyserr (moo_t* moo, int syserr_type, int syserr_code)
{ {
moo_errnum_t errnum;
if (moo->shuterr) return; if (moo->shuterr) return;
if (moo->vmprim.syserrstrb) if (moo->vmprim.syserrstrb)
{ {
moo->vmprim.syserrstrb (moo, syserr, moo->errmsg.tmpbuf.bch, MOO_COUNTOF(moo->errmsg.tmpbuf.bch)); errnum = moo->vmprim.syserrstrb (moo, syserr_type, syserr_code, moo->errmsg.tmpbuf.bch, MOO_COUNTOF(moo->errmsg.tmpbuf.bch));
moo_seterrbfmt (moo, moo_syserr_to_errnum(syserr), "%hs", moo->errmsg.tmpbuf.bch); moo_seterrbfmt (moo, errnum, "%hs", moo->errmsg.tmpbuf.bch);
} }
else else
{ {
MOO_ASSERT (moo, moo->vmprim.syserrstru != MOO_NULL); MOO_ASSERT (moo, moo->vmprim.syserrstru != MOO_NULL);
moo->vmprim.syserrstru (moo, syserr, moo->errmsg.tmpbuf.uch, MOO_COUNTOF(moo->errmsg.tmpbuf.uch)); errnum = moo->vmprim.syserrstru (moo, syserr_type, syserr_code, moo->errmsg.tmpbuf.uch, MOO_COUNTOF(moo->errmsg.tmpbuf.uch));
moo_seterrbfmt (moo, moo_syserr_to_errnum(syserr), "%ls", moo->errmsg.tmpbuf.uch); moo_seterrbfmt (moo, errnum, "%ls", moo->errmsg.tmpbuf.uch);
} }
} }

View File

@ -827,16 +827,162 @@ static void log_write (moo_t* moo, moo_bitmask_t mask, const moo_ooch_t* msg, mo
flush_log (moo, logfd); flush_log (moo, logfd);
} }
static void syserrstrb (moo_t* moo, int syserr, moo_bch_t* buf, moo_oow_t len) static moo_errnum_t errno_to_errnum (int errcode)
{ {
switch (errcode)
{
case ENOMEM: return MOO_ESYSMEM;
case EINVAL: return MOO_EINVAL;
#if defined(EBUSY)
case EBUSY: return MOO_EBUSY;
#endif
case EACCES: return MOO_EACCES;
#if defined(EPERM)
case EPERM: return MOO_EPERM;
#endif
#if defined(ENOTDIR)
case ENOTDIR: return MOO_ENOTDIR;
#endif
case ENOENT: return MOO_ENOENT;
#if defined(EEXIST)
case EEXIST: return MOO_EEXIST;
#endif
#if defined(EINTR)
case EINTR: return MOO_EINTR;
#endif
#if defined(EPIPE)
case EPIPE: return MOO_EPIPE;
#endif
#if defined(EAGAIN) && defined(EWOULDBLOCK) && (EAGAIN != EWOULDBLOCK)
case EAGAIN:
case EWOULDBLOCK: return MOO_EAGAIN;
#elif defined(EAGAIN)
case EAGAIN: return MOO_EAGAIN;
#elif defined(EWOULDBLOCK)
case EWOULDBLOCK: return MOO_EAGAIN;
#endif
#if defined(EBADF)
case EBADF: return MOO_EBADHND;
#endif
#if defined(EIO)
case EIO: return MOO_EIOERR;
#endif
default: return MOO_ESYSERR;
}
}
#if defined(_WIN32)
static moo_errnum_t winerr_to_errnum (DWORD errcode)
{
return MOO_ESYSERR;
}
#endif
#if defined(__OS2__)
static moo_errnum_t os2err_to_errnum (APIRET errcode)
{
/* APIRET e */
switch (errcode)
{
case ERROR_NOT_ENOUGH_MEMORY:
return MOO_ESYSMEM;
case ERROR_INVALID_PARAMETER:
case ERROR_INVALID_HANDLE:
case ERROR_INVALID_NAME:
return MOO_EINVAL;
case ERROR_ACCESS_DENIED:
case ERROR_SHARING_VIOLATION:
return MOO_EACCES;
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
return MOO_ENOENT;
case ERROR_ALREADY_EXISTS:
return MOO_EEXIST;
/*TODO: add more mappings */
default:
return MOO_ESYSERR;
}
}
#endif
#if defined(macintosh)
static moo_errnum_t macerr_to_errnum (int errcode)
{
switch (e)
{
case notEnoughMemoryErr:
return MOO_ESYSMEM;
case paramErr:
return MOO_EINVAL;
case qErr: /* queue element not found during deletion */
case fnfErr: /* file not found */
case dirNFErr: /* direcotry not found */
case resNotFound: /* resource not found */
case resFNotFound: /* resource file not found */
case nbpNotFound: /* name not found on remove */
return MOO_ENOENT;
/*TODO: add more mappings */
default:
return MOO_ESYSERR;
}
}
#endif
static moo_errnum_t syserrstrb (moo_t* moo, int syserr_type, int syserr_code, moo_bch_t* buf, moo_oow_t len)
{
switch (syserr_type)
{
case 1:
#if defined(_WIN32)
DWORD rc;
rc = FormatMessageA (
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, syserr_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
buf, len, MOO_NULL
);
while (rc > 0 && buf[rc - 1] == '\r' || buf[rc - 1] == '\n') buf[--rc] = '\0';
return winerr_to_errnum(syserr_code);
#elif defined(__OS2__)
/* TODO: convert code to string */
moo_copy_bcstr (buf, len, "system error");
return os2err_to_errnum(syserr_code);
#elif defined(macintosh)
/* TODO: convert code to string */
moo_copy_bcstr (buf, len, "system error");
return os2err_to_errnum(syserr_code);
#else
/* in other systems, errno is still the native system error code.
* fall thru */
#endif
case 0:
#if defined(HAVE_STRERROR_R) #if defined(HAVE_STRERROR_R)
strerror_r (syserr, buf, len); strerror_r (syserr_code, buf, len);
#else #else
/* this is not thread safe */ /* this is not thread safe */
moo_copy_bcstr (buf, len, strerror(syserr)); moo_copy_bcstr (buf, len, strerror(syserr_code));
#endif #endif
return errno_to_errnum(syserr_code);
} }
moo_copy_bcstr (buf, len, "system error");
return MOO_ESYSERR;
}
/* ========================================================================= */ /* ========================================================================= */
#if defined(USE_WIN_DLL) #if defined(USE_WIN_DLL)
@ -1177,7 +1323,7 @@ static int _add_poll_fd (moo_t* moo, int fd, int event_mask)
ev.revents = 0; ev.revents = 0;
if (write(xtn->ep, &ev, MOO_SIZEOF(ev)) != MOO_SIZEOF(ev)) if (write(xtn->ep, &ev, MOO_SIZEOF(ev)) != MOO_SIZEOF(ev))
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
MOO_DEBUG2 (moo, "Cannot add file descriptor %d to devpoll - %hs\n", fd, strerror(errno)); MOO_DEBUG2 (moo, "Cannot add file descriptor %d to devpoll - %hs\n", fd, strerror(errno));
return -1; return -1;
} }
@ -1201,7 +1347,7 @@ static int _add_poll_fd (moo_t* moo, int fd, int event_mask)
ev.data.fd = fd; ev.data.fd = fd;
if (epoll_ctl(xtn->ep, EPOLL_CTL_ADD, fd, &ev) == -1) if (epoll_ctl(xtn->ep, EPOLL_CTL_ADD, fd, &ev) == -1)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
MOO_DEBUG2 (moo, "Cannot add file descriptor %d to epoll - %hs\n", fd, strerror(errno)); MOO_DEBUG2 (moo, "Cannot add file descriptor %d to epoll - %hs\n", fd, strerror(errno));
return -1; return -1;
} }
@ -1281,7 +1427,7 @@ static int _del_poll_fd (moo_t* moo, int fd)
ev.revents = 0; ev.revents = 0;
if (write (xtn->ep, &ev, MOO_SIZEOF(ev)) != MOO_SIZEOF(ev)) if (write (xtn->ep, &ev, MOO_SIZEOF(ev)) != MOO_SIZEOF(ev))
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
MOO_DEBUG2 (moo, "Cannot remove file descriptor %d from devpoll - %hs\n", fd, strerror(errno)); MOO_DEBUG2 (moo, "Cannot remove file descriptor %d from devpoll - %hs\n", fd, strerror(errno));
return -1; return -1;
} }
@ -1296,7 +1442,7 @@ static int _del_poll_fd (moo_t* moo, int fd)
memset (&ev, 0, MOO_SIZEOF(ev)); memset (&ev, 0, MOO_SIZEOF(ev));
if (epoll_ctl (xtn->ep, EPOLL_CTL_DEL, fd, &ev) == -1) if (epoll_ctl (xtn->ep, EPOLL_CTL_DEL, fd, &ev) == -1)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
MOO_DEBUG2 (moo, "Cannot remove file descriptor %d from epoll - %hs\n", fd, strerror(errno)); MOO_DEBUG2 (moo, "Cannot remove file descriptor %d from epoll - %hs\n", fd, strerror(errno));
return -1; return -1;
} }
@ -1384,7 +1530,7 @@ static int _mod_poll_fd (moo_t* moo, int fd, int event_mask)
ev.data.fd = fd; ev.data.fd = fd;
if (epoll_ctl(xtn->ep, EPOLL_CTL_MOD, fd, &ev) == -1) if (epoll_ctl(xtn->ep, EPOLL_CTL_MOD, fd, &ev) == -1)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
MOO_DEBUG2 (moo, "Cannot modify file descriptor %d in epoll - %hs\n", fd, strerror(errno)); MOO_DEBUG2 (moo, "Cannot modify file descriptor %d in epoll - %hs\n", fd, strerror(errno));
return -1; return -1;
} }
@ -1457,7 +1603,7 @@ static int vm_startup (moo_t* moo)
xtn->ep = open("/dev/poll", O_RDWR); xtn->ep = open("/dev/poll", O_RDWR);
if (xtn->ep == -1) if (xtn->ep == -1)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
MOO_DEBUG1 (moo, "Cannot create devpoll - %hs\n", strerror(errno)); MOO_DEBUG1 (moo, "Cannot create devpoll - %hs\n", strerror(errno));
goto oops; goto oops;
} }
@ -1473,7 +1619,7 @@ static int vm_startup (moo_t* moo)
#endif #endif
if (xtn->ep == -1) if (xtn->ep == -1)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
MOO_DEBUG1 (moo, "Cannot create epoll - %hs\n", strerror(errno)); MOO_DEBUG1 (moo, "Cannot create epoll - %hs\n", strerror(errno));
goto oops; goto oops;
} }
@ -1499,7 +1645,7 @@ static int vm_startup (moo_t* moo)
#if defined(USE_THREAD) #if defined(USE_THREAD)
if (pipe(xtn->p) == -1) if (pipe(xtn->p) == -1)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
MOO_DEBUG1 (moo, "Cannot create pipes - %hs\n", strerror(errno)); MOO_DEBUG1 (moo, "Cannot create pipes - %hs\n", strerror(errno));
goto oops; goto oops;
} }
@ -2093,7 +2239,7 @@ static void vm_muxwait (moo_t* moo, const moo_ntime_t* dur, moo_vmprim_muxwait_c
if (n <= -1) if (n <= -1)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
MOO_DEBUG2 (moo, "Warning: multiplexer wait failure - %d, %s\n", errno, moo_geterrmsg(moo)); MOO_DEBUG2 (moo, "Warning: multiplexer wait failure - %d, %s\n", errno, moo_geterrmsg(moo));
} }
else else

View File

@ -1069,16 +1069,18 @@ typedef void (*moo_log_write_t) (
moo_oow_t len moo_oow_t len
); );
typedef void (*moo_syserrstrb_t) ( typedef moo_errnum_t (*moo_syserrstrb_t) (
moo_t* moo, moo_t* moo,
int syserr, int syserr_type,
int syserr_code,
moo_bch_t* buf, moo_bch_t* buf,
moo_oow_t len moo_oow_t len
); );
typedef void (*moo_syserrstru_t) ( typedef moo_errnum_t (*moo_syserrstru_t) (
moo_t* moo, moo_t* moo,
int syserr, int syserr_type,
int syserr_code,
moo_uch_t* buf, moo_uch_t* buf,
moo_oow_t len moo_oow_t len
); );
@ -1794,7 +1796,8 @@ MOO_EXPORT void moo_seterrnum (
MOO_EXPORT void moo_seterrwithsyserr ( MOO_EXPORT void moo_seterrwithsyserr (
moo_t* moo, moo_t* moo,
int syserr int syserr_type,
int syserr_code
); );
MOO_EXPORT void moo_seterrbfmt ( MOO_EXPORT void moo_seterrbfmt (
@ -2296,10 +2299,6 @@ MOO_EXPORT void moo_assertfailed (
moo_oow_t line moo_oow_t line
); );
MOO_EXPORT moo_errnum_t moo_syserr_to_errnum (
int syserr
);
MOO_EXPORT const moo_ooch_t* moo_errnum_to_errstr ( MOO_EXPORT const moo_ooch_t* moo_errnum_to_errstr (
moo_errnum_t errnum moo_errnum_t errnum
); );

View File

@ -89,7 +89,7 @@ create_socket:
goto create_socket; goto create_socket;
} }
#endif #endif
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
goto oops; goto oops;
} }
@ -110,7 +110,7 @@ create_socket:
if (fl == -1) if (fl == -1)
{ {
fcntl_failure: fcntl_failure:
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
goto oops; goto oops;
} }
@ -150,7 +150,7 @@ static moo_pfrc_t pf_close_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
moo_releaseiohandle (moo, MOO_OOP_TO_SMOOI(sck->handle)); moo_releaseiohandle (moo, MOO_OOP_TO_SMOOI(sck->handle));
if (close(MOO_OOP_TO_SMOOI(sck->handle)) == -1) if (close(MOO_OOP_TO_SMOOI(sck->handle)) == -1)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }
else else
@ -191,7 +191,7 @@ static moo_pfrc_t pf_bind_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &enable, MOO_SIZEOF(int)) == -1 || if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &enable, MOO_SIZEOF(int)) == -1 ||
bind(fd, (struct sockaddr*)MOO_OBJ_GET_BYTE_SLOT(arg), moo_sck_addr_len((sck_addr_t*)MOO_OBJ_GET_BYTE_SLOT(arg))) == -1) bind(fd, (struct sockaddr*)MOO_OBJ_GET_BYTE_SLOT(arg), moo_sck_addr_len((sck_addr_t*)MOO_OBJ_GET_BYTE_SLOT(arg))) == -1)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }
@ -231,7 +231,7 @@ static moo_pfrc_t pf_accept_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
if (errno != EWOULDBLOCK && errno != EAGAIN) if (errno != EWOULDBLOCK && errno != EAGAIN)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }
@ -251,7 +251,7 @@ normal_accept:
{ {
if (errno != EWOULDBLOCK && errno != EAGAIN) if (errno != EWOULDBLOCK && errno != EAGAIN)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }
@ -264,7 +264,7 @@ normal_accept:
if (fl == -1) if (fl == -1)
{ {
fcntl_failure: fcntl_failure:
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
close (newfd); close (newfd);
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }
@ -339,7 +339,7 @@ static moo_pfrc_t pf_listen_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
n = listen(fd, MOO_OOP_TO_SMOOI(arg)); n = listen(fd, MOO_OOP_TO_SMOOI(arg));
if (n == -1) if (n == -1)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }
@ -381,7 +381,7 @@ static moo_pfrc_t pf_connect_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs
} }
else else
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }
} }
@ -413,7 +413,7 @@ static moo_pfrc_t pf_get_socket_error (moo_t* moo, moo_mod_t* mod, moo_ooi_t nar
len = MOO_SIZEOF(ret); len = MOO_SIZEOF(ret);
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (char*)&ret, &len) == -1) if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (char*)&ret, &len) == -1)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }
@ -484,7 +484,7 @@ static moo_pfrc_t pf_read_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
n = recv(fd, &MOO_OBJ_GET_BYTE_SLOT(buf)[offset], length, 0); n = recv(fd, &MOO_OBJ_GET_BYTE_SLOT(buf)[offset], length, 0);
if (n <= -1 && errno != EWOULDBLOCK && errno != EAGAIN) if (n <= -1 && errno != EWOULDBLOCK && errno != EAGAIN)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }
@ -557,7 +557,7 @@ static moo_pfrc_t pf_write_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
n = send(fd, &MOO_OBJ_GET_BYTE_SLOT(buf)[offset], length, 0); n = send(fd, &MOO_OBJ_GET_BYTE_SLOT(buf)[offset], length, 0);
if (n <= -1 && errno != EWOULDBLOCK && errno != EAGAIN) if (n <= -1 && errno != EWOULDBLOCK && errno != EAGAIN)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }

View File

@ -75,7 +75,7 @@ static moo_pfrc_t pf_open (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
#endif #endif
if (!stdio->fp) if (!stdio->fp)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
goto softfail; goto softfail;
} }
@ -157,7 +157,7 @@ static moo_pfrc_t __pf_puts (moo_t* moo, moo_ooi_t nargs, moo_oow_t limit)
if (fwrite (bcs, 1, bcslen, stdio->fp) < bcslen) if (fwrite (bcs, 1, bcslen, stdio->fp) < bcslen)
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
goto softfail; goto softfail;
} }
@ -169,7 +169,7 @@ static moo_pfrc_t __pf_puts (moo_t* moo, moo_ooi_t nargs, moo_oow_t limit)
puts_string: puts_string:
if (fwrite (x->slot, 1, MOO_OBJ_GET_SIZE(x), stdio->fp) < MOO_OBJ_GET_SIZE(x)) if (fwrite (x->slot, 1, MOO_OBJ_GET_SIZE(x), stdio->fp) < MOO_OBJ_GET_SIZE(x))
{ {
moo_seterrwithsyserr (moo, errno); moo_seterrwithsyserr (moo, 0, errno);
goto softfail; goto softfail;
} }
#endif #endif