You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by ab...@apache.org on 2014/01/07 08:07:40 UTC
svn commit: r1556126 - in /incubator/celix/trunk:
framework/private/src/celix_errorcodes.c
framework/public/include/celix_errno.h log_service/private/src/log.c
Author: abroekhuis
Date: Tue Jan 7 07:07:39 2014
New Revision: 1556126
URL: http://svn.apache.org/r1556126
Log:
CELIX-103: Applied patch and updated code to have better error handling.
Modified:
incubator/celix/trunk/framework/private/src/celix_errorcodes.c
incubator/celix/trunk/framework/public/include/celix_errno.h
incubator/celix/trunk/log_service/private/src/log.c
Modified: incubator/celix/trunk/framework/private/src/celix_errorcodes.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/celix_errorcodes.c?rev=1556126&r1=1556125&r2=1556126&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/celix_errorcodes.c (original)
+++ incubator/celix/trunk/framework/private/src/celix_errorcodes.c Tue Jan 7 07:07:39 2014
@@ -45,6 +45,8 @@ static char *celix_error_string(celix_st
return "Framework exception";
case CELIX_FILE_IO_EXCEPTION:
return "File I/O exception";
+ case CELIX_SERVICE_EXCEPTION:
+ return "Service exception";
}
return "Unkown code";
}
Modified: incubator/celix/trunk/framework/public/include/celix_errno.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/celix_errno.h?rev=1556126&r1=1556125&r2=1556126&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/celix_errno.h (original)
+++ incubator/celix/trunk/framework/public/include/celix_errno.h Tue Jan 7 07:07:39 2014
@@ -101,6 +101,7 @@ FRAMEWORK_EXPORT char *celix_strerror(ce
#define CELIX_ILLEGAL_STATE (CELIX_START_ERROR + 6)
#define CELIX_FRAMEWORK_EXCEPTION (CELIX_START_ERROR + 7)
#define CELIX_FILE_IO_EXCEPTION (CELIX_START_ERROR + 8)
+#define CELIX_SERVICE_EXCEPTION (CELIX_START_ERROR + 9)
#define CELIX_ENOMEM ENOMEM
Modified: incubator/celix/trunk/log_service/private/src/log.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/log_service/private/src/log.c?rev=1556126&r1=1556125&r2=1556126&view=diff
==============================================================================
--- incubator/celix/trunk/log_service/private/src/log.c (original)
+++ incubator/celix/trunk/log_service/private/src/log.c Tue Jan 7 07:07:39 2014
@@ -220,23 +220,27 @@ celix_status_t log_addLogListener(log_pt
celix_status_t log_removeLogListener(log_pt logger, log_listener_pt listener) {
celix_status_t status = CELIX_SUCCESS;
- apr_status_t apr_status;
+ celix_status_t threadStatus = CELIX_SUCCESS;
- apr_status = apr_thread_mutex_lock(logger->deliverLock);
- apr_status = apr_thread_mutex_lock(logger->listenerLock);
- if (apr_status != APR_SUCCESS) {
- status = CELIX_INVALID_SYNTAX;
- } else {
+ status = CELIX_DO_IF(status, apr_thread_mutex_lock(logger->deliverLock));
+ status = CELIX_DO_IF(status, apr_thread_mutex_lock(logger->listenerLock));
+ if (status == CELIX_SUCCESS) {
arrayList_removeElement(logger->listeners, listener);
if (arrayList_size(logger->listeners) == 0) {
- log_stopListenerThread(logger);
+ status = log_stopListenerThread(logger);
}
- apr_status = apr_thread_mutex_unlock(logger->listenerLock);
- apr_status = apr_thread_mutex_unlock(logger->deliverLock);
- if (apr_status != APR_SUCCESS) {
- status = CELIX_INVALID_SYNTAX;
+ status = CELIX_DO_IF(status, apr_thread_mutex_unlock(logger->listenerLock));
+ status = CELIX_DO_IF(status, apr_thread_mutex_unlock(logger->deliverLock));
+ status = CELIX_DO_IF(status, apr_thread_join(&threadStatus, logger->listenerThread));
+ if (status == CELIX_SUCCESS) {
+ logger->listenerThread = NULL;
}
+ status = threadStatus;
+ }
+
+ if (status != CELIX_SUCCESS) {
+ status = CELIX_SERVICE_EXCEPTION;
}
return status;
@@ -281,17 +285,13 @@ static celix_status_t log_stopListenerTh
apr_status_t apr_status = APR_SUCCESS;
if (apr_status != APR_SUCCESS) {
- status = CELIX_INVALID_SYNTAX;
+ status = CELIX_SERVICE_EXCEPTION;
} else {
logger->running = false;
- apr_thread_cond_signal(logger->entriesToDeliver);
+ status = apr_thread_cond_signal(logger->entriesToDeliver);
if (status != APR_SUCCESS) {
- status = CELIX_INVALID_SYNTAX;
- } else {
-// apr_thread_join(&status, logger->listenerThread);
- logger->listenerThread = NULL;
+ status = CELIX_SERVICE_EXCEPTION;
}
-
}
return status;