incubator-celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1423140 - in /incubator/celix/trunk/remote_shell: ./ private/include/ private/src/
Date Mon, 17 Dec 2012 20:57:16 GMT
Author: abroekhuis
Date: Mon Dec 17 20:57:14 2012
New Revision: 1423140

URL: http://svn.apache.org/viewvc?rev=1423140&view=rev
Log:
CELIX-44: Small code changes to support windows

Modified:
    incubator/celix/trunk/remote_shell/CMakeLists.txt
    incubator/celix/trunk/remote_shell/private/include/connection_listener.h
    incubator/celix/trunk/remote_shell/private/include/remote_shell.h
    incubator/celix/trunk/remote_shell/private/include/shell_mediator.h
    incubator/celix/trunk/remote_shell/private/src/activator.c
    incubator/celix/trunk/remote_shell/private/src/connection_listener.c
    incubator/celix/trunk/remote_shell/private/src/remote_shell.c
    incubator/celix/trunk/remote_shell/private/src/shell_mediator.c

Modified: incubator/celix/trunk/remote_shell/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_shell/CMakeLists.txt?rev=1423140&r1=1423139&r2=1423140&view=diff
==============================================================================
--- incubator/celix/trunk/remote_shell/CMakeLists.txt (original)
+++ incubator/celix/trunk/remote_shell/CMakeLists.txt Mon Dec 17 20:57:14 2012
@@ -14,26 +14,24 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-celix_subproject(REMOTE_SHELL "Option to enable building the Remote Shell bundles" OFF DEPS
LAUNCHER SHELL)
+celix_subproject(REMOTE_SHELL "Option to enable building the Remote Shell bundles" OFF DEPS
LAUNCHER SHELL_TUI)
 if (REMOTE_SHELL)
 
 	SET_HEADER(BUNDLE_SYMBOLICNAME "apache_celix_remote_shell")
 	SET_HEADERS("Bundle-Name: Apache Celix Remote Shell") 
 	
-
     bundle(remote_shell SOURCES 
     	private/src/activator 
     	private/src/connection_listener 
     	private/src/shell_mediator 
     	private/src/remote_shell
 	)
-    
  
     include_directories("private/include")
     include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
     include_directories("${PROJECT_SOURCE_DIR}/shell/public/include")
     
-    target_link_libraries(remote_shell celix_framework apr-1 aprutil-1)
+    target_link_libraries(remote_shell celix_framework ${APRUTIL_LIBRARY})
     
     package(remote_shell)
     

Modified: incubator/celix/trunk/remote_shell/private/include/connection_listener.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_shell/private/include/connection_listener.h?rev=1423140&r1=1423139&r2=1423140&view=diff
==============================================================================
--- incubator/celix/trunk/remote_shell/private/include/connection_listener.h (original)
+++ incubator/celix/trunk/remote_shell/private/include/connection_listener.h Mon Dec 17 20:57:14
2012
@@ -27,14 +27,12 @@
 #ifndef connectionListener_H_
 #define connectionListener_H_
 
-#include "remote_shell.h"
-
 #include <apr_pools.h>
 
 #include <bundle_context.h>
 #include <celix_errno.h>
 
-
+#include "remote_shell.h"
 
 typedef struct connection_listener *connection_listener_t;
 

Modified: incubator/celix/trunk/remote_shell/private/include/remote_shell.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_shell/private/include/remote_shell.h?rev=1423140&r1=1423139&r2=1423140&view=diff
==============================================================================
--- incubator/celix/trunk/remote_shell/private/include/remote_shell.h (original)
+++ incubator/celix/trunk/remote_shell/private/include/remote_shell.h Mon Dec 17 20:57:14
2012
@@ -27,13 +27,12 @@
 #ifndef REMOTE_SHELL_H_
 #define REMOTE_SHELL_H_
 
-#include "shell_mediator.h"
-
 #include <apr_pools.h>
 
 #include <bundle_context.h>
 #include <celix_errno.h>
 
+#include "shell_mediator.h"
 
 typedef struct remote_shell *remote_shell_t;
 

Modified: incubator/celix/trunk/remote_shell/private/include/shell_mediator.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_shell/private/include/shell_mediator.h?rev=1423140&r1=1423139&r2=1423140&view=diff
==============================================================================
--- incubator/celix/trunk/remote_shell/private/include/shell_mediator.h (original)
+++ incubator/celix/trunk/remote_shell/private/include/shell_mediator.h Mon Dec 17 20:57:14
2012
@@ -33,7 +33,6 @@
 #include <bundle_context.h>
 #include <celix_errno.h>
 
-
 typedef struct shell_mediator *shell_mediator_t;
 
 celix_status_t shellMediator_create(apr_pool_t *pool, bundle_context_t context, shell_mediator_t
*instance);

Modified: incubator/celix/trunk/remote_shell/private/src/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_shell/private/src/activator.c?rev=1423140&r1=1423139&r2=1423140&view=diff
==============================================================================
--- incubator/celix/trunk/remote_shell/private/src/activator.c (original)
+++ incubator/celix/trunk/remote_shell/private/src/activator.c Mon Dec 17 20:57:14 2012
@@ -57,8 +57,10 @@ static apr_int64_t bundleActivator_getPr
 
 celix_status_t bundleActivator_create(bundle_context_t context, void **userData) {
 	celix_status_t status = CELIX_SUCCESS;
+    apr_pool_t *ctxpool;
     apr_pool_t *pool;
-    status = bundleContext_getMemoryPool(context, &pool);
+    status = bundleContext_getMemoryPool(context, &ctxpool);
+    apr_pool_create(&pool, ctxpool);
     if (status == CELIX_SUCCESS) {
     	bundle_instance_t bi = apr_palloc(pool, sizeof(struct bundle_instance));
         if (userData != NULL) {

Modified: incubator/celix/trunk/remote_shell/private/src/connection_listener.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_shell/private/src/connection_listener.c?rev=1423140&r1=1423139&r2=1423140&view=diff
==============================================================================
--- incubator/celix/trunk/remote_shell/private/src/connection_listener.c (original)
+++ incubator/celix/trunk/remote_shell/private/src/connection_listener.c Mon Dec 17 20:57:14
2012
@@ -24,13 +24,7 @@
  *  \copyright	Apache License, Version 2.0
  */
 
-
-#include "connection_listener.h"
-
-#include "shell_mediator.h"
-#include "remote_shell.h"
-
-#include <celix_errno.h>
+#include <stdlib.h>
 
 #include <apr_pools.h>
 #include <apr_thread_mutex.h>
@@ -39,6 +33,13 @@
 #include <apr_poll.h>
 #include <apr_thread_pool.h>
 
+#include <celix_errno.h>
+
+#include "connection_listener.h"
+
+#include "shell_mediator.h"
+#include "remote_shell.h"
+
 struct connection_listener {
 	//constant
     apr_pool_t *pool;
@@ -58,12 +59,12 @@ celix_status_t connectionListener_create
 	celix_status_t status = CELIX_SUCCESS;
     (*instance) = apr_palloc(pool, sizeof(**instance));
     if ((*instance) != NULL) {
-    	(*instance)->pool=pool;
-    	(*instance)->port=port;
-		(*instance)->mutex=NULL;
-		(*instance)->remoteShell=remoteShell;
-		(*instance)->thread=NULL;
-		(*instance)->pollset=NULL;
+    	(*instance)->pool = pool;
+    	(*instance)->port = port;
+		(*instance)->mutex = NULL;
+		(*instance)->remoteShell = remoteShell;
+		(*instance)->thread = NULL;
+		(*instance)->pollset = NULL;
 		apr_pool_pre_cleanup_register(pool, (*instance), (void *)connectionListener_cleanup);
 
 		status = apr_thread_mutex_create(&(*instance)->mutex, APR_THREAD_MUTEX_DEFAULT,
pool);
@@ -91,9 +92,10 @@ celix_status_t connectionListener_start(
 
 celix_status_t connectionListener_stop(connection_listener_t instance) {
 	celix_status_t status = CELIX_SUCCESS;
+	apr_thread_t *thread = NULL;
+	apr_pollset_t *pollset = NULL;
+
 	printf("CONNECTION_LISTENER: Stopping thread\n");
-	apr_thread_t *thread;
-	apr_pollset_t *pollset;
 
 	apr_thread_mutex_lock(instance->mutex);
 	thread=instance->thread;
@@ -102,10 +104,14 @@ celix_status_t connectionListener_stop(c
 	apr_thread_mutex_unlock(instance->mutex);
 
 	if (thread != NULL && pollset != NULL) {
+		apr_status_t threadStatus = APR_SUCCESS;
+
 		printf("Stopping thread by waking poll on listen socket\n");
-		apr_pollset_wakeup(pollset);
+		apr_status_t stat = apr_pollset_wakeup(pollset);
+		char error[512];
+		apr_strerror(stat, error, 512);
+		printf("Got error %s\n", error);
 
-		apr_status_t threadStatus;
 		apr_thread_join(&threadStatus, thread);
 		printf("Done joining thread\n");
 	} else if (thread != NULL) {
@@ -117,8 +123,7 @@ celix_status_t connectionListener_stop(c
 	return status;
 }
 
-static void* APR_THREAD_FUNC connection_listener_thread(apr_thread_t *thread, void *data)
-{
+static void* APR_THREAD_FUNC connection_listener_thread(apr_thread_t *thread, void *data)
{
 	apr_status_t status = APR_SUCCESS;
 	connection_listener_t instance = data;
 
@@ -144,21 +149,24 @@ static void* APR_THREAD_FUNC connection_
     instance->pollset=pollset;
     apr_thread_mutex_unlock(instance->mutex);
 
-    if (status != CELIX_SUCCESS) {
+    if (status != APR_SUCCESS) {
     	char error[64];
 		apr_strerror(status, error, 64);
     	printf("Error creating and listing on socket: %s\n", error);
     } else {
-    	printf("Remote Shell accepting connections on port %lld\n", instance->port);
+    	printf("Remote Shell accepting connections on port %li\n", instance->port);
     }
 
-	while (status == CELIX_SUCCESS) {
+	while (status == APR_SUCCESS) {
 		status = apr_pollset_poll(pollset, -1, &num, &ret_pfd); //blocks on fd till a connection
is made
 		if (status == APR_SUCCESS) {
-			acceptedSocket = NULL;
+			apr_status_t socketStatus = APR_SUCCESS;
 			apr_pool_t *socketPool = NULL;
+
+			acceptedSocket = NULL;
 			apr_pool_create(&socketPool, instance->pool);
-			apr_status_t socketStatus = apr_socket_accept(&acceptedSocket, listenSocket, socketPool);
+			socketStatus = apr_socket_accept(&acceptedSocket, listenSocket, socketPool);
+
 			printf("REMOTE_SHELL: created connection socket\n");
 			if (socketStatus == APR_SUCCESS) {
 				remoteShell_addConnection(instance->remoteShell, acceptedSocket);

Modified: incubator/celix/trunk/remote_shell/private/src/remote_shell.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_shell/private/src/remote_shell.c?rev=1423140&r1=1423139&r2=1423140&view=diff
==============================================================================
--- incubator/celix/trunk/remote_shell/private/src/remote_shell.c (original)
+++ incubator/celix/trunk/remote_shell/private/src/remote_shell.c Mon Dec 17 20:57:14 2012
@@ -24,9 +24,6 @@
  *  \copyright	Apache License, Version 2.0
  */
 
-
-#include "remote_shell.h"
-
 #include <stdlib.h>
 
 #include <apr_pools.h>
@@ -38,13 +35,15 @@
 #include <utils.h>
 #include <array_list.h>
 
+#include "remote_shell.h"
+
 #define COMMAND_BUFF_SIZE (256)
 
-#define PROMPT ("-> ")
-#define WELCOME ("\n---- Apache Celix Remote Shell ----\n---- Type exit to disconnect   ----\n\n->
")
-#define GOODBYE ("Goobye!\n")
-#define ERROR ("Error executing command!\n")
-#define MAXIMUM_CONNECTIONS_REACHED ("Maximum number of connections  reached. Disconnecting
...\n")
+#define RS_PROMPT ("-> ")
+#define RS_WELCOME ("\n---- Apache Celix Remote Shell ----\n---- Type exit to disconnect
  ----\n\n-> ")
+#define RS_GOODBYE ("Goobye!\n")
+#define RS_ERROR ("Error executing command!\n")
+#define RS_MAXIMUM_CONNECTIONS_REACHED ("Maximum number of connections  reached. Disconnecting
...\n")
 
 struct remote_shell {
 	apr_pool_t *pool;
@@ -78,7 +77,7 @@ celix_status_t remoteShell_create(apr_po
 	if ((*instance) != NULL) {
 		(*instance)->pool = pool;
 		(*instance)->mediator = mediator;
-		(*instance)->maximumConnections=maximumConnections;
+		(*instance)->maximumConnections = maximumConnections;
 		(*instance)->threadPool = NULL;
 		(*instance)->mutex = NULL;
 		(*instance)->connections = NULL;
@@ -121,7 +120,7 @@ celix_status_t remoteShell_addConnection
 			status = apr_thread_pool_push(instance->threadPool, remoteShell_connection_run, connection,
0, instance);
 		} else {
 			status = APR_ECONNREFUSED;
-			remoteShell_connection_print(connection, MAXIMUM_CONNECTIONS_REACHED);
+			remoteShell_connection_print(connection, RS_MAXIMUM_CONNECTIONS_REACHED);
 		}
 		apr_thread_mutex_unlock(instance->mutex);
 	} else {
@@ -163,29 +162,31 @@ void * remoteShell_connection_run(apr_th
 	apr_size_t len;
 	char buff[COMMAND_BUFF_SIZE];
 	apr_pollfd_t pfd = { connection->pool, APR_POLL_SOCKET, APR_POLLIN, 0, { NULL }, NULL
};
-	pfd.desc.s = connection->socket;
 	apr_int32_t num;
 	const apr_pollfd_t *ret_pfd;
 
+	pfd.desc.s = connection->socket;
+
 	status = CELIX_DO_IF(status, apr_pollset_add(connection->pollset, &pfd));
 
-	remoteShell_connection_print(connection, WELCOME);
+	remoteShell_connection_print(connection, RS_WELCOME);
 	while (status == CELIX_SUCCESS) {
 		status = apr_pollset_poll(connection->pollset, -1, &num, &ret_pfd); //blocks
on fd until a connection is made
 		if (status == APR_SUCCESS) {
 			len = COMMAND_BUFF_SIZE -1;
 			status = apr_socket_recv(connection->socket, buff, &len);
 			if (status == APR_SUCCESS && len < COMMAND_BUFF_SIZE) {
+				apr_status_t commandStatus = APR_SUCCESS;
 				buff[len]='\0';
-				apr_status_t commandStatus = remoteShell_connection_execute(connection, buff);
+				commandStatus = remoteShell_connection_execute(connection, buff);
 				if (commandStatus == CELIX_SUCCESS) {
-					remoteShell_connection_print(connection, PROMPT);
+					remoteShell_connection_print(connection, RS_PROMPT);
 				} else if (commandStatus == APR_EOF) {
 					//exit command
 					break;
 				} else { //error
-					remoteShell_connection_print(connection, ERROR);
-					remoteShell_connection_print(connection, PROMPT);
+					remoteShell_connection_print(connection, RS_ERROR);
+					remoteShell_connection_print(connection, RS_PROMPT);
 				}
 
 			} else {
@@ -202,7 +203,7 @@ void * remoteShell_connection_run(apr_th
 			break;
 		}
 	}
-	remoteShell_connection_print(connection, GOODBYE);
+	remoteShell_connection_print(connection, RS_GOODBYE);
 
 	printf("Closing socket\n");
 	apr_thread_mutex_lock(connection->parent->mutex);

Modified: incubator/celix/trunk/remote_shell/private/src/shell_mediator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_shell/private/src/shell_mediator.c?rev=1423140&r1=1423139&r2=1423140&view=diff
==============================================================================
--- incubator/celix/trunk/remote_shell/private/src/shell_mediator.c (original)
+++ incubator/celix/trunk/remote_shell/private/src/shell_mediator.c Mon Dec 17 20:57:14 2012
@@ -24,9 +24,6 @@
  *  \copyright	Apache License, Version 2.0
  */
 
-
-#include "shell_mediator.h"
-
 #include <stdlib.h>
 
 #include <apr_pools.h>
@@ -37,6 +34,8 @@
 #include <service_tracker.h>
 #include <command.h>
 
+#include "shell_mediator.h"
+
 struct shell_mediator {
     apr_pool_t *pool;
 	bundle_context_t context;
@@ -65,12 +64,13 @@ celix_status_t shellMediator_create(apr_
 
     (*instance) = apr_palloc(pool, sizeof(**instance));
     if ((*instance) != NULL) {
-    	(*instance)->pool=pool;
-		(*instance)->context=context;
-		(*instance)->tracker=NULL;
-		(*instance)->mutex=NULL;
-		(*instance)->shellService=NULL;
-		apr_pool_pre_cleanup_register(pool, (*instance), (void *)shellMediator_cleanup);
+		apr_pool_pre_cleanup_register(pool, *instance, (void *)shellMediator_cleanup);
+
+    	(*instance)->pool = pool;
+		(*instance)->context = context;
+		(*instance)->tracker = NULL;
+		(*instance)->mutex = NULL;
+		(*instance)->shellService = NULL;
 
 		status = apr_thread_mutex_create(&(*instance)->mutex, APR_THREAD_MUTEX_DEFAULT,
pool);
 		status = CELIX_DO_IF(status, serviceTrackerCustomizer_create(pool, (*instance), shellMediator_addingService,
shellMediator_addedService,



Mime
View raw message