renamed stop to halt in some context.

renamed start to execute in TcpServer
This commit is contained in:
hyung-hwan 2019-11-12 07:55:32 +00:00
parent ae997bb477
commit af7852ee6c
19 changed files with 72 additions and 72 deletions

View File

@ -160,7 +160,7 @@ static void stop_run (void* arg)
int e = errno; int e = errno;
#endif #endif
qse_awk_rtx_stop (app_rtx); qse_awk_rtx_halt (app_rtx);
#if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__) #if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__)
errno = e; errno = e;

View File

@ -493,7 +493,7 @@ static void stop_run (void* arg)
int e = errno; int e = errno;
#endif #endif
qse_sed_stop (g_sed); qse_sed_halt (g_sed);
#if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__) #if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__)
errno = e; errno = e;
@ -879,7 +879,7 @@ static int sed_main (int argc, qse_char_t* argv[])
QSE_MMGR_FREE (qse_sed_getmmgr(sed), tmpl_tmpfile); QSE_MMGR_FREE (qse_sed_getmmgr(sed), tmpl_tmpfile);
} }
if (qse_sed_isstop (sed)) break; if (qse_sed_ishalt (sed)) break;
} }
if (output) qse_sio_close (output->u.sio); if (output) qse_sio_close (output->u.sio);

View File

@ -861,8 +861,8 @@ public:
operator Awk* () const; operator Awk* () const;
operator rtx_t* () const; operator rtx_t* () const;
void stop () const; void halt () const;
bool isStop () const; bool isHalt () const;
errnum_t getErrorNumber () const; errnum_t getErrorNumber () const;
loc_t getErrorLocation () const; loc_t getErrorLocation () const;
@ -1047,9 +1047,9 @@ public:
); );
/// ///
/// The stop() function makes request to abort execution /// The halt() function makes request to abort execution
/// ///
void stop (); void halt ();
/// \} /// \}
/// ///

View File

@ -2344,26 +2344,26 @@ QSE_EXPORT qse_awk_val_t* qse_awk_rtx_callwithstrs (
); );
/** /**
* The qse_awk_stopall() function aborts all active runtime contexts * The qse_awk_haltall() function aborts all active runtime contexts
* associated with \a awk. * associated with \a awk.
*/ */
QSE_EXPORT void qse_awk_stopall ( QSE_EXPORT void qse_awk_haltall (
qse_awk_t* awk /**< awk */ qse_awk_t* awk /**< awk */
); );
/** /**
* The qse_awk_rtx_isstop() function tests if qse_awk_rtx_stop() has been * The qse_awk_rtx_ishalt() function tests if qse_awk_rtx_halt() has been
* called. * called.
*/ */
QSE_EXPORT int qse_awk_rtx_isstop ( QSE_EXPORT int qse_awk_rtx_ishalt (
qse_awk_rtx_t* rtx /**< runtime context */ qse_awk_rtx_t* rtx /**< runtime context */
); );
/** /**
* The qse_awk_rtx_stop() function causes an active runtime context \a rtx to * The qse_awk_rtx_halt() function causes an active runtime context \a rtx to
* be aborted. * be aborted.
*/ */
QSE_EXPORT void qse_awk_rtx_stop ( QSE_EXPORT void qse_awk_rtx_halt (
qse_awk_rtx_t* rtx /**< runtime context */ qse_awk_rtx_t* rtx /**< runtime context */
); );

View File

@ -201,17 +201,17 @@ public:
int execute (Stream& iostream); int execute (Stream& iostream);
/// ///
/// The stop() function makes a request to break a running loop /// The halt() function makes a request to break a running loop
/// inside execute(). Note that this does not affect blocking /// inside execute(). Note that this does not affect blocking
/// operations in user-defined stream handlers. /// operations in user-defined stream handlers.
/// ///
void stop (); void halt ();
/// ///
/// The isStop() function returns true if stop() has been called /// The isHalt() function returns true if halt() has been called
/// since the last call to execute(), false otherwise. /// since the last call to execute(), false otherwise.
/// ///
bool isStop () const; bool isHalt () const;
/// ///
/// The getTrait() function gets the current traits. /// The getTrait() function gets the current traits.

View File

@ -644,17 +644,17 @@ QSE_EXPORT int qse_sed_exec (
); );
/** /**
* The qse_sed_stop() function breaks running loop in qse_sed_exec(). * The qse_sed_halt() function breaks running loop in qse_sed_exec().
* It doesn't affect blocking calls in stream handlers. * It doesn't affect blocking calls in stream handlers.
*/ */
QSE_EXPORT void qse_sed_stop ( QSE_EXPORT void qse_sed_halt (
qse_sed_t* sed /**< stream editor */ qse_sed_t* sed /**< stream editor */
); );
/** /**
* The qse_sed_isstop() functions tests if qse_sed_stop() is called. * The qse_sed_ishalt() functions tests if qse_sed_halt() is called.
*/ */
QSE_EXPORT int qse_sed_isstop ( QSE_EXPORT int qse_sed_ishalt (
qse_sed_t* sed /**< stream editor */ qse_sed_t* sed /**< stream editor */
); );

View File

@ -47,8 +47,8 @@ public:
TcpServer (Mmgr* mmgr = QSE_NULL) QSE_CPP_NOEXCEPT; TcpServer (Mmgr* mmgr = QSE_NULL) QSE_CPP_NOEXCEPT;
virtual ~TcpServer () QSE_CPP_NOEXCEPT; virtual ~TcpServer () QSE_CPP_NOEXCEPT;
virtual int start (const qse_char_t* addrs) QSE_CPP_NOEXCEPT; virtual int execute (const qse_char_t* addrs) QSE_CPP_NOEXCEPT;
virtual int stop () QSE_CPP_NOEXCEPT; virtual int halt () QSE_CPP_NOEXCEPT;
bool isServing () const QSE_CPP_NOEXCEPT bool isServing () const QSE_CPP_NOEXCEPT
{ {
@ -57,11 +57,11 @@ public:
bool isStopRequested () const QSE_CPP_NOEXCEPT bool isStopRequested () const QSE_CPP_NOEXCEPT
{ {
return this->_stop_requested; return this->_halt_requested;
} }
void setStopRequested (bool req) QSE_CPP_NOEXCEPT void setStopRequested (bool req) QSE_CPP_NOEXCEPT
{ {
this->_stop_requested = req; this->_halt_requested = req;
} }
qse_size_t getMaxConnections () const QSE_CPP_NOEXCEPT qse_size_t getMaxConnections () const QSE_CPP_NOEXCEPT
@ -117,7 +117,7 @@ public:
Connection (Listener* listener) QSE_CPP_NOEXCEPT: listener(listener), prev_connection(QSE_NULL), next_connection(QSE_NULL), claimed(false), wid(_wid_map_t::WID_INVALID) {} Connection (Listener* listener) QSE_CPP_NOEXCEPT: listener(listener), prev_connection(QSE_NULL), next_connection(QSE_NULL), claimed(false), wid(_wid_map_t::WID_INVALID) {}
int main (); int main ();
int stop () QSE_CPP_NOEXCEPT; int halt () QSE_CPP_NOEXCEPT;
Listener* getListener() QSE_CPP_NOEXCEPT { return this->listener; } Listener* getListener() QSE_CPP_NOEXCEPT { return this->listener; }
const Listener* getListener() const QSE_CPP_NOEXCEPT { return this->listener; } const Listener* getListener() const QSE_CPP_NOEXCEPT { return this->listener; }
@ -140,7 +140,7 @@ public:
QSE::Socket socket; QSE::Socket socket;
QSE::SocketAddress address; QSE::SocketAddress address;
QSE::SpinLock csspl; // spin lock for connection stop QSE::SpinLock csspl; // spin lock for connection halt
}; };
private: private:
@ -238,7 +238,7 @@ private:
ListenerList _listener_list; ListenerList _listener_list;
ConnectionList _connection_list[2]; ConnectionList _connection_list[2];
QSE::SpinLock _connection_list_spl; QSE::SpinLock _connection_list_spl;
bool _stop_requested; bool _halt_requested;
bool _server_serving; bool _server_serving;
qse_size_t _max_connections; qse_size_t _max_connections;
qse_size_t _thread_stack_size; qse_size_t _thread_stack_size;

View File

@ -1099,16 +1099,16 @@ Awk::Run::operator Awk::rtx_t* () const
return this->rtx; return this->rtx;
} }
void Awk::Run::stop () const void Awk::Run::halt () const
{ {
QSE_ASSERT (this->rtx != QSE_NULL); QSE_ASSERT (this->rtx != QSE_NULL);
qse_awk_rtx_stop (this->rtx); qse_awk_rtx_halt (this->rtx);
} }
bool Awk::Run::isStop () const bool Awk::Run::isHalt () const
{ {
QSE_ASSERT (this->rtx != QSE_NULL); QSE_ASSERT (this->rtx != QSE_NULL);
return qse_awk_rtx_isstop (this->rtx)? true: false; return qse_awk_rtx_ishalt (this->rtx)? true: false;
} }
Awk::errnum_t Awk::Run::getErrorNumber () const Awk::errnum_t Awk::Run::getErrorNumber () const
@ -1576,10 +1576,10 @@ int Awk::call (const qse_wchar_t* name, Value* ret, const Value* args, size_t na
return 0; return 0;
} }
void Awk::stop () void Awk::halt ()
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
qse_awk_stopall (awk); qse_awk_haltall (awk);
} }
int Awk::init_runctx () int Awk::init_runctx ()

View File

@ -311,7 +311,7 @@ struct qse_awk_t
qse_mchar_t merrmsg[QSE_AWK_ERRINF_MSG_SIZE * 2]; qse_mchar_t merrmsg[QSE_AWK_ERRINF_MSG_SIZE * 2];
#endif #endif
int stopall; int haltall;
qse_awk_ecb_t* ecb; qse_awk_ecb_t* ecb;
qse_rbt_t* modtab; qse_rbt_t* modtab;

View File

@ -155,7 +155,7 @@ int qse_awk_init (qse_awk_t* awk, qse_mmgr_t* mmgr, const qse_awk_prm_t* prm)
awk->errinf.loc.colm = 0; awk->errinf.loc.colm = 0;
awk->errinf.loc.file = QSE_NULL; awk->errinf.loc.file = QSE_NULL;
awk->errstr = qse_awk_dflerrstr; awk->errstr = qse_awk_dflerrstr;
awk->stopall = 0; awk->haltall = 0;
/* progagate the primitive functions */ /* progagate the primitive functions */
QSE_ASSERT (prm != QSE_NULL); QSE_ASSERT (prm != QSE_NULL);
@ -327,7 +327,7 @@ void qse_awk_clear (qse_awk_t* awk)
if (ecb->clear) ecb->clear (awk); if (ecb->clear) ecb->clear (awk);
} }
awk->stopall = 0; awk->haltall = 0;
clear_token (&awk->tok); clear_token (&awk->tok);
clear_token (&awk->ntok); clear_token (&awk->ntok);
@ -525,9 +525,9 @@ int qse_awk_getopt (qse_awk_t* awk, qse_awk_opt_t id, void* value)
return -1; return -1;
} }
void qse_awk_stopall (qse_awk_t* awk) void qse_awk_haltall (qse_awk_t* awk)
{ {
awk->stopall = 1; awk->haltall = 1;
qse_awk_seterrnum (awk, QSE_AWK_EINVAL, QSE_NULL); qse_awk_seterrnum (awk, QSE_AWK_EINVAL, QSE_NULL);
} }

View File

@ -851,14 +851,14 @@ void qse_awk_rtx_close (qse_awk_rtx_t* rtx)
qse_awk_freemem (rtx->awk, rtx); qse_awk_freemem (rtx->awk, rtx);
} }
void qse_awk_rtx_stop (qse_awk_rtx_t* rtx) void qse_awk_rtx_halt (qse_awk_rtx_t* rtx)
{ {
rtx->exit_level = EXIT_ABORT; rtx->exit_level = EXIT_ABORT;
} }
int qse_awk_rtx_isstop (qse_awk_rtx_t* rtx) int qse_awk_rtx_ishalt (qse_awk_rtx_t* rtx)
{ {
return (rtx->exit_level == EXIT_ABORT || rtx->awk->stopall); return (rtx->exit_level == EXIT_ABORT || rtx->awk->haltall);
} }
void qse_awk_rtx_getrio (qse_awk_rtx_t* rtx, qse_awk_rio_t* rio) void qse_awk_rtx_getrio (qse_awk_rtx_t* rtx, qse_awk_rio_t* rio)
@ -1436,7 +1436,7 @@ static qse_awk_val_t* run_bpae_loop (qse_awk_rtx_t* rtx)
} }
/* execute END blocks. the first END block is executed if the /* execute END blocks. the first END block is executed if the
* program is not explicitly aborted with qse_awk_rtx_stop().*/ * program is not explicitly aborted with qse_awk_rtx_halt().*/
for (nde = rtx->awk->tree.end; for (nde = rtx->awk->tree.end;
ret == 0 && nde != QSE_NULL && rtx->exit_level < EXIT_ABORT; ret == 0 && nde != QSE_NULL && rtx->exit_level < EXIT_ABORT;
nde = nde->next) nde = nde->next)
@ -1574,7 +1574,7 @@ qse_awk_val_t* qse_awk_rtx_callfun (qse_awk_rtx_t* rtx, qse_awk_fun_t* fun, qse_
if (rtx->exit_level >= EXIT_GLOBAL) if (rtx->exit_level >= EXIT_GLOBAL)
{ {
/* cannot call the function again when exit() is called /* cannot call the function again when exit() is called
* in an AWK program or qse_awk_rtx_stop() is invoked */ * in an AWK program or qse_awk_rtx_halt() is invoked */
SETERR_COD (rtx, QSE_AWK_EPERM); SETERR_COD (rtx, QSE_AWK_EPERM);
return QSE_NULL; return QSE_NULL;
} }
@ -1950,7 +1950,7 @@ static int run_block (qse_awk_rtx_t* rtx, qse_awk_nde_blk_t* nde)
#define ON_STATEMENT(rtx,nde) QSE_BLOCK ( \ #define ON_STATEMENT(rtx,nde) QSE_BLOCK ( \
qse_awk_rtx_ecb_t* ecb; \ qse_awk_rtx_ecb_t* ecb; \
if ((rtx)->awk->stopall) (rtx)->exit_level = EXIT_ABORT; \ if ((rtx)->awk->haltall) (rtx)->exit_level = EXIT_ABORT; \
for (ecb = (rtx)->ecb; ecb; ecb = ecb->next) \ for (ecb = (rtx)->ecb; ecb; ecb = ecb->next) \
if (ecb->stmt) ecb->stmt (rtx, nde); \ if (ecb->stmt) ecb->stmt (rtx, nde); \
) )

View File

@ -90,16 +90,16 @@ int Sed::execute (Stream& iostream)
return qse_sed_exec (sed, xin, xout); return qse_sed_exec (sed, xin, xout);
} }
void Sed::stop () void Sed::halt ()
{ {
QSE_ASSERT (sed != QSE_NULL); QSE_ASSERT (sed != QSE_NULL);
qse_sed_stop (sed); qse_sed_halt (sed);
} }
bool Sed::isStop () const bool Sed::isHalt () const
{ {
QSE_ASSERT (sed != QSE_NULL); QSE_ASSERT (sed != QSE_NULL);
return qse_sed_isstop (sed); return qse_sed_ishalt (sed);
} }
int Sed::getTrait () const int Sed::getTrait () const

View File

@ -217,8 +217,8 @@ struct qse_sed_t
int subst_done; int subst_done;
void* last_rex; void* last_rex;
/** stop requested */ /** halt requested */
int stopreq; int haltreq;
} e; } e;
}; };

View File

@ -3953,7 +3953,7 @@ int qse_sed_exec (qse_sed_t* sed, qse_sed_io_impl_t inf, qse_sed_io_impl_t outf)
#endif #endif
}; };
sed->e.stopreq = 0; sed->e.haltreq = 0;
sed->e.last_rex = QSE_NULL; sed->e.last_rex = QSE_NULL;
sed->e.subst_done = 0; sed->e.subst_done = 0;
@ -4020,7 +4020,7 @@ int qse_sed_exec (qse_sed_t* sed, qse_sed_io_impl_t inf, qse_sed_io_impl_t outf)
goto done; goto done;
} }
while (!sed->e.stopreq) while (!sed->e.haltreq)
{ {
#if defined(QSE_ENABLE_SED_TRACER) #if defined(QSE_ENABLE_SED_TRACER)
if (sed->opt.tracer) sed->opt.tracer (sed, QSE_SED_TRACER_READ, QSE_NULL); if (sed->opt.tracer) sed->opt.tracer (sed, QSE_SED_TRACER_READ, QSE_NULL);
@ -4068,7 +4068,7 @@ int qse_sed_exec (qse_sed_t* sed, qse_sed_io_impl_t inf, qse_sed_io_impl_t outf)
if (emit_output (sed, 0) <= -1) ret = -1; if (emit_output (sed, 0) <= -1) ret = -1;
goto done; goto done;
} }
if (sed->e.stopreq) goto done; if (sed->e.haltreq) goto done;
if (j == &sed->cmd.again) goto again; if (j == &sed->cmd.again) goto again;
/* go to the next command */ /* go to the next command */
@ -4093,14 +4093,14 @@ done3:
return ret; return ret;
} }
void qse_sed_stop (qse_sed_t* sed) void qse_sed_halt (qse_sed_t* sed)
{ {
sed->e.stopreq = 1; sed->e.haltreq = 1;
} }
int qse_sed_isstop (qse_sed_t* sed) int qse_sed_ishalt (qse_sed_t* sed)
{ {
return sed->e.stopreq; return sed->e.haltreq;
} }
const qse_char_t* qse_sed_getcompid (qse_sed_t* sed) const qse_char_t* qse_sed_getcompid (qse_sed_t* sed)

View File

@ -72,7 +72,7 @@ int TcpServer::Connection::main ()
return n; return n;
} }
int TcpServer::Connection::stop () QSE_CPP_NOEXCEPT int TcpServer::Connection::halt () QSE_CPP_NOEXCEPT
{ {
// the receiver will be notified of the end of // the receiver will be notified of the end of
// the connection by the socket's closing. // the connection by the socket's closing.
@ -86,7 +86,7 @@ int TcpServer::Connection::stop () QSE_CPP_NOEXCEPT
TcpServer::TcpServer (Mmgr* mmgr) QSE_CPP_NOEXCEPT: TcpServer::TcpServer (Mmgr* mmgr) QSE_CPP_NOEXCEPT:
Mmged(mmgr), Mmged(mmgr),
_stop_requested(false), _halt_requested(false),
_server_serving(false), _server_serving(false),
_max_connections(0), _max_connections(0),
_thread_stack_size(0) _thread_stack_size(0)
@ -164,7 +164,7 @@ void TcpServer::dispatch_mux_event (qse_mux_t* mux, const qse_mux_evt_t* evt) QS
if (evt->data == NULL) if (evt->data == NULL)
{ {
/* just consume data written by TcpServer::stop() */ /* just consume data written by TcpServer::halt() */
char tmp[128]; char tmp[128];
while (::read(server->_listener_list.mux_pipe[0], tmp, QSE_SIZEOF(tmp)) > 0) /* nothing */; while (::read(server->_listener_list.mux_pipe[0], tmp, QSE_SIZEOF(tmp)) > 0) /* nothing */;
} }
@ -210,7 +210,7 @@ void TcpServer::dispatch_mux_event (qse_mux_t* mux, const qse_mux_evt_t* evt) QS
if (lerr == Socket::E_EINTR || lerr == Socket::E_EAGAIN) return; if (lerr == Socket::E_EINTR || lerr == Socket::E_EAGAIN) return;
server->setErrorNumber (lerr); server->setErrorNumber (lerr);
server->stop (); server->halt ();
return; return;
} }
@ -409,7 +409,7 @@ oops:
return -1; return -1;
} }
int TcpServer::start (const qse_char_t* addrs) QSE_CPP_NOEXCEPT int TcpServer::execute (const qse_char_t* addrs) QSE_CPP_NOEXCEPT
{ {
int xret = 0; int xret = 0;
@ -471,7 +471,7 @@ int TcpServer::start (const qse_char_t* addrs) QSE_CPP_NOEXCEPT
return xret; return xret;
} }
int TcpServer::stop () QSE_CPP_NOEXCEPT int TcpServer::halt () QSE_CPP_NOEXCEPT
{ {
if (this->_server_serving) if (this->_server_serving)
{ {

View File

@ -246,7 +246,7 @@ static int setsignal (int sig, void(*handler)(int), int restart)
static void stop_run (int sig) static void stop_run (int sig)
{ {
int e = errno; int e = errno;
if (app_awk) app_awk->stop (); if (app_awk) app_awk->halt ();
errno = e; errno = e;
} }
#endif #endif

View File

@ -200,7 +200,7 @@ int main (int argc, char* argv[])
case '?': case '?':
case ':': case ':':
print_usage (qse_basenameasmbs(argv[0])); print_usage (qse_mbsbasename(argv[0]));
return -1; return -1;
} }
} }

View File

@ -71,7 +71,7 @@ public:
// TODO: don't call stop() if this processs is a guardian // TODO: don't call stop() if this processs is a guardian
// though it's no harm to call stop(). // though it's no harm to call stop().
QSE_APP_LOG3 (this, QSE_LOG_INFO, QSE_T("requesting to stop server...app %p server %p - pid %d\n"), this, &this->server, (int)getpid()); QSE_APP_LOG3 (this, QSE_LOG_INFO, QSE_T("requesting to stop server...app %p server %p - pid %d\n"), this, &this->server, (int)getpid());
this->server.stop(); this->server.halt();
break; break;
} }
} }
@ -100,7 +100,7 @@ public:
QSE_APP_LOG0 (this, QSE_LOG_INFO, QSE_T(" <tcpsvr01r> ")); QSE_APP_LOG0 (this, QSE_LOG_INFO, QSE_T(" <tcpsvr01r> "));
QSE_APP_LOG0 (this, QSE_LOG_INFO, QSE_T("started\n")); QSE_APP_LOG0 (this, QSE_LOG_INFO, QSE_T("started\n"));
this->server.setThreadStackSize (256000); this->server.setThreadStackSize (256000);
return this->server.start (QSE_T("[::]:9998,0.0.0.0:9998")); return this->server.execute(QSE_T("[::]:9998,0.0.0.0:9998"));
} }
return -1; return -1;
} }

View File

@ -107,16 +107,16 @@ static int test1 (void)
server.setThreadStackSize (256000); server.setThreadStackSize (256000);
g_server = &server; g_server = &server;
//server.start (QSE_T("0.0.0.0:9998")); //server.execute (QSE_T("0.0.0.0:9998"));
server.start (QSE_T("[::]:9998,0.0.0.0:9998")); server.execute (QSE_T("[::]:9998,0.0.0.0:9998"));
//server.start (QSE_T("[fe80::1c4:a90d:a0f0:d52%wlan0]:9998,0.0.0.0:9998")); //server.execute (QSE_T("[fe80::1c4:a90d:a0f0:d52%wlan0]:9998,0.0.0.0:9998"));
g_server = QSE_NULL; g_server = QSE_NULL;
return 0; return 0;
} }
static void handle_sigint (int sig) static void handle_sigint (int sig)
{ {
if (g_server) g_server->stop (); if (g_server) g_server->halt ();
} }
int main () int main ()