From: David van Moolenbroek Date: Mon, 9 Apr 2012 14:35:57 +0000 (+0200) Subject: SEF: add sef_cancel() X-Git-Tag: v3.2.1~618 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch05.html?a=commitdiff_plain;h=060399d9ddb3418890fc8710399e39ada553716f;p=minix.git SEF: add sef_cancel() This function allows the caller to cancel receiving a message from a SEF callback. The receive function will then return EINTR. --- diff --git a/include/minix/sef.h b/include/minix/sef.h index 13f4debcb..d36d67bea 100644 --- a/include/minix/sef.h +++ b/include/minix/sef.h @@ -8,6 +8,7 @@ /* SEF entry points for system processes. */ void sef_startup(void); int sef_receive_status(endpoint_t src, message *m_ptr, int *status_ptr); +void sef_cancel(void); void sef_exit(int status); #define sef_receive(src, m_ptr) sef_receive_status(src, m_ptr, NULL) diff --git a/lib/libsys/sef.c b/lib/libsys/sef.c index 27f0aab0e..f1bc4eee8 100644 --- a/lib/libsys/sef.c +++ b/lib/libsys/sef.c @@ -12,6 +12,7 @@ char sef_self_name[SEF_SELF_NAME_MAXLEN]; endpoint_t sef_self_endpoint; int sef_self_priv_flags; int sef_self_first_receive_done; +int sef_self_receiving; /* Debug. */ #if SEF_INIT_DEBUG || SEF_LU_DEBUG || SEF_PING_DEBUG || SEF_SIGNAL_DEBUG @@ -119,7 +120,14 @@ int sef_receive_status(endpoint_t src, message *m_ptr, int *status_ptr) /* SEF receive() interface for system services. */ int r, status; + sef_self_receiving = TRUE; + while(TRUE) { + /* If the caller indicated that it no longer wants to receive a message, + * return now. + */ + if (!sef_self_receiving) + return EINTR; #if INTERCEPT_SEF_LU_REQUESTS /* Handle SEF Live update before receive events. */ @@ -180,6 +188,20 @@ int sef_receive_status(endpoint_t src, message *m_ptr, int *status_ptr) return r; } +/*===========================================================================* + * sef_cancel * + *===========================================================================*/ +void sef_cancel(void) +{ +/* Cancel receiving a message. This function be called from a callback invoked + * from within sef_receive_status(), which will then return an EINTR error + * code. In particular, this function can be used to exit from the main receive + * loop when a signal handler causes the process to want to shut down. + */ + + sef_self_receiving = FALSE; +} + /*===========================================================================* * sef_exit * *===========================================================================*/