renamed stop to halt in some context.
renamed start to execute in TcpServer
This commit is contained in:
parent
ae997bb477
commit
af7852ee6c
@ -160,7 +160,7 @@ static void stop_run (void* arg)
|
||||
int e = errno;
|
||||
#endif
|
||||
|
||||
qse_awk_rtx_stop (app_rtx);
|
||||
qse_awk_rtx_halt (app_rtx);
|
||||
|
||||
#if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__)
|
||||
errno = e;
|
||||
|
@ -493,7 +493,7 @@ static void stop_run (void* arg)
|
||||
int e = errno;
|
||||
#endif
|
||||
|
||||
qse_sed_stop (g_sed);
|
||||
qse_sed_halt (g_sed);
|
||||
|
||||
#if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__)
|
||||
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);
|
||||
}
|
||||
|
||||
if (qse_sed_isstop (sed)) break;
|
||||
if (qse_sed_ishalt (sed)) break;
|
||||
}
|
||||
|
||||
if (output) qse_sio_close (output->u.sio);
|
||||
|
@ -861,8 +861,8 @@ public:
|
||||
operator Awk* () const;
|
||||
operator rtx_t* () const;
|
||||
|
||||
void stop () const;
|
||||
bool isStop () const;
|
||||
void halt () const;
|
||||
bool isHalt () const;
|
||||
|
||||
errnum_t getErrorNumber () 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 ();
|
||||
/// \}
|
||||
|
||||
///
|
||||
|
@ -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.
|
||||
*/
|
||||
QSE_EXPORT void qse_awk_stopall (
|
||||
QSE_EXPORT void qse_awk_haltall (
|
||||
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.
|
||||
*/
|
||||
QSE_EXPORT int qse_awk_rtx_isstop (
|
||||
QSE_EXPORT int qse_awk_rtx_ishalt (
|
||||
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.
|
||||
*/
|
||||
QSE_EXPORT void qse_awk_rtx_stop (
|
||||
QSE_EXPORT void qse_awk_rtx_halt (
|
||||
qse_awk_rtx_t* rtx /**< runtime context */
|
||||
);
|
||||
|
||||
|
@ -201,17 +201,17 @@ public:
|
||||
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
|
||||
/// 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.
|
||||
///
|
||||
bool isStop () const;
|
||||
bool isHalt () const;
|
||||
|
||||
///
|
||||
/// The getTrait() function gets the current traits.
|
||||
|
@ -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.
|
||||
*/
|
||||
QSE_EXPORT void qse_sed_stop (
|
||||
QSE_EXPORT void qse_sed_halt (
|
||||
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 */
|
||||
);
|
||||
|
||||
|
@ -47,8 +47,8 @@ public:
|
||||
TcpServer (Mmgr* mmgr = QSE_NULL) QSE_CPP_NOEXCEPT;
|
||||
virtual ~TcpServer () QSE_CPP_NOEXCEPT;
|
||||
|
||||
virtual int start (const qse_char_t* addrs) QSE_CPP_NOEXCEPT;
|
||||
virtual int stop () QSE_CPP_NOEXCEPT;
|
||||
virtual int execute (const qse_char_t* addrs) QSE_CPP_NOEXCEPT;
|
||||
virtual int halt () QSE_CPP_NOEXCEPT;
|
||||
|
||||
bool isServing () const QSE_CPP_NOEXCEPT
|
||||
{
|
||||
@ -57,11 +57,11 @@ public:
|
||||
|
||||
bool isStopRequested () const QSE_CPP_NOEXCEPT
|
||||
{
|
||||
return this->_stop_requested;
|
||||
return this->_halt_requested;
|
||||
}
|
||||
void setStopRequested (bool req) QSE_CPP_NOEXCEPT
|
||||
{
|
||||
this->_stop_requested = req;
|
||||
this->_halt_requested = req;
|
||||
}
|
||||
|
||||
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) {}
|
||||
|
||||
int main ();
|
||||
int stop () QSE_CPP_NOEXCEPT;
|
||||
int halt () QSE_CPP_NOEXCEPT;
|
||||
|
||||
Listener* getListener() 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::SocketAddress address;
|
||||
QSE::SpinLock csspl; // spin lock for connection stop
|
||||
QSE::SpinLock csspl; // spin lock for connection halt
|
||||
};
|
||||
|
||||
private:
|
||||
@ -238,7 +238,7 @@ private:
|
||||
ListenerList _listener_list;
|
||||
ConnectionList _connection_list[2];
|
||||
QSE::SpinLock _connection_list_spl;
|
||||
bool _stop_requested;
|
||||
bool _halt_requested;
|
||||
bool _server_serving;
|
||||
qse_size_t _max_connections;
|
||||
qse_size_t _thread_stack_size;
|
||||
|
@ -1099,16 +1099,16 @@ Awk::Run::operator Awk::rtx_t* () const
|
||||
return this->rtx;
|
||||
}
|
||||
|
||||
void Awk::Run::stop () const
|
||||
void Awk::Run::halt () const
|
||||
{
|
||||
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);
|
||||
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
|
||||
@ -1576,10 +1576,10 @@ int Awk::call (const qse_wchar_t* name, Value* ret, const Value* args, size_t na
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Awk::stop ()
|
||||
void Awk::halt ()
|
||||
{
|
||||
QSE_ASSERT (awk != QSE_NULL);
|
||||
qse_awk_stopall (awk);
|
||||
qse_awk_haltall (awk);
|
||||
}
|
||||
|
||||
int Awk::init_runctx ()
|
||||
|
@ -311,7 +311,7 @@ struct qse_awk_t
|
||||
qse_mchar_t merrmsg[QSE_AWK_ERRINF_MSG_SIZE * 2];
|
||||
#endif
|
||||
|
||||
int stopall;
|
||||
int haltall;
|
||||
qse_awk_ecb_t* ecb;
|
||||
|
||||
qse_rbt_t* modtab;
|
||||
|
@ -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.file = QSE_NULL;
|
||||
awk->errstr = qse_awk_dflerrstr;
|
||||
awk->stopall = 0;
|
||||
awk->haltall = 0;
|
||||
|
||||
/* progagate the primitive functions */
|
||||
QSE_ASSERT (prm != QSE_NULL);
|
||||
@ -327,7 +327,7 @@ void qse_awk_clear (qse_awk_t* awk)
|
||||
if (ecb->clear) ecb->clear (awk);
|
||||
}
|
||||
|
||||
awk->stopall = 0;
|
||||
awk->haltall = 0;
|
||||
|
||||
clear_token (&awk->tok);
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -851,14 +851,14 @@ void qse_awk_rtx_close (qse_awk_rtx_t* 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;
|
||||
}
|
||||
|
||||
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)
|
||||
@ -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
|
||||
* 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;
|
||||
ret == 0 && nde != QSE_NULL && rtx->exit_level < EXIT_ABORT;
|
||||
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)
|
||||
{
|
||||
/* 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);
|
||||
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 ( \
|
||||
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) \
|
||||
if (ecb->stmt) ecb->stmt (rtx, nde); \
|
||||
)
|
||||
|
@ -90,16 +90,16 @@ int Sed::execute (Stream& iostream)
|
||||
return qse_sed_exec (sed, xin, xout);
|
||||
}
|
||||
|
||||
void Sed::stop ()
|
||||
void Sed::halt ()
|
||||
{
|
||||
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);
|
||||
return qse_sed_isstop (sed);
|
||||
return qse_sed_ishalt (sed);
|
||||
}
|
||||
|
||||
int Sed::getTrait () const
|
||||
|
@ -217,8 +217,8 @@ struct qse_sed_t
|
||||
int subst_done;
|
||||
void* last_rex;
|
||||
|
||||
/** stop requested */
|
||||
int stopreq;
|
||||
/** halt requested */
|
||||
int haltreq;
|
||||
} e;
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
sed->e.stopreq = 0;
|
||||
sed->e.haltreq = 0;
|
||||
sed->e.last_rex = QSE_NULL;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
while (!sed->e.stopreq)
|
||||
while (!sed->e.haltreq)
|
||||
{
|
||||
#if defined(QSE_ENABLE_SED_TRACER)
|
||||
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;
|
||||
goto done;
|
||||
}
|
||||
if (sed->e.stopreq) goto done;
|
||||
if (sed->e.haltreq) goto done;
|
||||
if (j == &sed->cmd.again) goto again;
|
||||
|
||||
/* go to the next command */
|
||||
@ -4093,14 +4093,14 @@ done3:
|
||||
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)
|
||||
|
@ -72,7 +72,7 @@ int TcpServer::Connection::main ()
|
||||
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 connection by the socket's closing.
|
||||
@ -86,7 +86,7 @@ int TcpServer::Connection::stop () QSE_CPP_NOEXCEPT
|
||||
|
||||
TcpServer::TcpServer (Mmgr* mmgr) QSE_CPP_NOEXCEPT:
|
||||
Mmged(mmgr),
|
||||
_stop_requested(false),
|
||||
_halt_requested(false),
|
||||
_server_serving(false),
|
||||
_max_connections(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)
|
||||
{
|
||||
/* just consume data written by TcpServer::stop() */
|
||||
/* just consume data written by TcpServer::halt() */
|
||||
char tmp[128];
|
||||
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;
|
||||
|
||||
server->setErrorNumber (lerr);
|
||||
server->stop ();
|
||||
server->halt ();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -409,7 +409,7 @@ oops:
|
||||
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;
|
||||
|
||||
@ -471,7 +471,7 @@ int TcpServer::start (const qse_char_t* addrs) QSE_CPP_NOEXCEPT
|
||||
return xret;
|
||||
}
|
||||
|
||||
int TcpServer::stop () QSE_CPP_NOEXCEPT
|
||||
int TcpServer::halt () QSE_CPP_NOEXCEPT
|
||||
{
|
||||
if (this->_server_serving)
|
||||
{
|
||||
|
@ -246,7 +246,7 @@ static int setsignal (int sig, void(*handler)(int), int restart)
|
||||
static void stop_run (int sig)
|
||||
{
|
||||
int e = errno;
|
||||
if (app_awk) app_awk->stop ();
|
||||
if (app_awk) app_awk->halt ();
|
||||
errno = e;
|
||||
}
|
||||
#endif
|
||||
|
@ -200,7 +200,7 @@ int main (int argc, char* argv[])
|
||||
|
||||
case '?':
|
||||
case ':':
|
||||
print_usage (qse_basenameasmbs(argv[0]));
|
||||
print_usage (qse_mbsbasename(argv[0]));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
// TODO: don't call stop() if this processs is a guardian
|
||||
// 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());
|
||||
this->server.stop();
|
||||
this->server.halt();
|
||||
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("started\n"));
|
||||
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;
|
||||
}
|
||||
|
@ -107,16 +107,16 @@ static int test1 (void)
|
||||
|
||||
server.setThreadStackSize (256000);
|
||||
g_server = &server;
|
||||
//server.start (QSE_T("0.0.0.0:9998"));
|
||||
server.start (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("0.0.0.0:9998"));
|
||||
server.execute (QSE_T("[::]: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;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void handle_sigint (int sig)
|
||||
{
|
||||
if (g_server) g_server->stop ();
|
||||
if (g_server) g_server->halt ();
|
||||
}
|
||||
|
||||
int main ()
|
||||
|
Loading…
Reference in New Issue
Block a user