celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1628128 - in /celix/trunk/examples: ./ echo_service/client/ echo_service/client/private/include/ echo_service/client/private/src/ echo_service/server/
Date Mon, 29 Sep 2014 06:59:00 GMT
Author: abroekhuis
Date: Mon Sep 29 06:58:59 2014
New Revision: 1628128

URL: http://svn.apache.org/r1628128
Log:
CELIX-154: Applied (most of) the patch. Removed some compiler switches and other fixed to
keep the changes limited to the echo example.

Modified:
    celix/trunk/examples/CMakeLists.txt
    celix/trunk/examples/deploy.cmake
    celix/trunk/examples/echo_service/client/CMakeLists.txt
    celix/trunk/examples/echo_service/client/private/include/echo_client_private.h
    celix/trunk/examples/echo_service/client/private/src/echo_client.c
    celix/trunk/examples/echo_service/client/private/src/echo_client_activator.c
    celix/trunk/examples/echo_service/server/CMakeLists.txt

Modified: celix/trunk/examples/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/trunk/examples/CMakeLists.txt?rev=1628128&r1=1628127&r2=1628128&view=diff
==============================================================================
--- celix/trunk/examples/CMakeLists.txt (original)
+++ celix/trunk/examples/CMakeLists.txt Mon Sep 29 06:58:59 2014
@@ -21,7 +21,7 @@ if (EXAMPLES)
     #add_subdirectory(mongoose)
     
     #add_subdirectory(whiteboard)
-    #add_subdirectory(echo_service)
+    add_subdirectory(echo_service)
     
     add_subdirectory(osgi-in-action/chapter04-correct-lookup)
     add_subdirectory(osgi-in-action/chapter04-correct-listener)

Modified: celix/trunk/examples/deploy.cmake
URL: http://svn.apache.org/viewvc/celix/trunk/examples/deploy.cmake?rev=1628128&r1=1628127&r2=1628128&view=diff
==============================================================================
--- celix/trunk/examples/deploy.cmake (original)
+++ celix/trunk/examples/deploy.cmake Mon Sep 29 06:58:59 2014
@@ -22,5 +22,5 @@ if (EXAMPLES)
 	deploy("hello_world" BUNDLES shell shell_tui org.apache.incubator.celix.helloworld hello_world_test
log_service)
 	#deploy("wb" BUNDLES tracker publisherA publisherB shell shell_tui log_service log_writer)
 	#deploy("wb_dp" BUNDLES tracker_depman publisherA publisherB shell shell_tui log_service
log_writer)
-	#deploy("echo" BUNDLES echo_server echo_client shell shell_tui log_service log_writer)
+	deploy("echo" BUNDLES echo_server echo_client shell shell_tui)
 endif (EXAMPLES)
\ No newline at end of file

Modified: celix/trunk/examples/echo_service/client/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/trunk/examples/echo_service/client/CMakeLists.txt?rev=1628128&r1=1628127&r2=1628128&view=diff
==============================================================================
--- celix/trunk/examples/echo_service/client/CMakeLists.txt (original)
+++ celix/trunk/examples/echo_service/client/CMakeLists.txt Mon Sep 29 06:58:59 2014
@@ -15,6 +15,10 @@
 # specific language governing permissions and limitations
 # under the License.
 
+SET(BUNDLE_SYMBOLICNAME "apache_celix_examples_echo_client")
+SET(BUNDLE_VERSION "0.0.1")
+SET(BUNDLE_NAME "Apache Celix Echo Client")
+
 bundle(echo_client SOURCES 
 	private/src/echo_client_activator 
 	private/src/echo_client

Modified: celix/trunk/examples/echo_service/client/private/include/echo_client_private.h
URL: http://svn.apache.org/viewvc/celix/trunk/examples/echo_service/client/private/include/echo_client_private.h?rev=1628128&r1=1628127&r2=1628128&view=diff
==============================================================================
--- celix/trunk/examples/echo_service/client/private/include/echo_client_private.h (original)
+++ celix/trunk/examples/echo_service/client/private/include/echo_client_private.h Mon Sep
29 06:58:59 2014
@@ -32,14 +32,13 @@
 struct echoClient {
 	service_tracker_pt tracker;
 	bool running;
-	apr_pool_t *pool;
-
-	apr_thread_t *sender;
+	pthread_t sender_thread;
+	char *ident;
 };
 
 typedef struct echoClient * echo_client_pt;
 
-echo_client_pt echoClient_create(service_tracker_pt context, apr_pool_t *pool);
+echo_client_pt echoClient_create(service_tracker_pt context);
 
 void echoClient_start(echo_client_pt client);
 void echoClient_stop(echo_client_pt client);

Modified: celix/trunk/examples/echo_service/client/private/src/echo_client.c
URL: http://svn.apache.org/viewvc/celix/trunk/examples/echo_service/client/private/src/echo_client.c?rev=1628128&r1=1628127&r2=1628128&view=diff
==============================================================================
--- celix/trunk/examples/echo_service/client/private/src/echo_client.c (original)
+++ celix/trunk/examples/echo_service/client/private/src/echo_client.c Mon Sep 29 06:58:59
2014
@@ -24,49 +24,54 @@
  *  \copyright	Apache License, Version 2.0
  */
 #include <stdlib.h>
+#include <pthread.h>
+#include <unistd.h>
 
 #include "service_tracker.h"
 
 #include "echo_client_private.h"
 #include "echo_server.h"
 
-static void *APR_THREAD_FUNC trk_send(apr_thread_t *thd, void *handle) {
+static void *trk_send(void *handle) {
+
 	echo_client_pt client = (echo_client_pt) handle;
+
 	while (client->running) {
 		echo_service_pt service = (echo_service_pt) serviceTracker_getService(client->tracker);
 		if (service != NULL) {
-			service->echo(service->server, "hi");
+			service->echo(service->server, client->ident);
 		}
-		apr_sleep(1000000);
+		sleep(1);
 	}
-	apr_thread_exit(thd, APR_SUCCESS);
+
+	pthread_exit(NULL);
+
 	return NULL;
 }
 
-echo_client_pt echoClient_create(service_tracker_pt echoServiceTracker, apr_pool_t *pool)
{
+echo_client_pt echoClient_create(service_tracker_pt echoServiceTracker) {
 	echo_client_pt client = malloc(sizeof(*client));
 
 	client->tracker = echoServiceTracker;
 	client->running = false;
-	client->pool = pool;
+	client->ident = "OSX rules";
 
 	return client;
 }
 
 void echoClient_start(echo_client_pt client) {
 	client->running = true;
-	apr_thread_create(&client->sender, NULL, trk_send, client, client->pool);
+	pthread_create(&client->sender_thread, NULL, trk_send, client);
 }
 
 void echoClient_stop(echo_client_pt client) {
-	apr_status_t status;
 	client->running = false;
-	apr_thread_join(&status, client->sender);
+	pthread_join(client->sender_thread, NULL);
 }
 
 void echoClient_destroy(echo_client_pt client) {
 	client->tracker = NULL;
-	client->sender = 0;
+	client->sender_thread = 0;
 	free(client);
 	client = NULL;
 }

Modified: celix/trunk/examples/echo_service/client/private/src/echo_client_activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/examples/echo_service/client/private/src/echo_client_activator.c?rev=1628128&r1=1628127&r2=1628128&view=diff
==============================================================================
--- celix/trunk/examples/echo_service/client/private/src/echo_client_activator.c (original)
+++ celix/trunk/examples/echo_service/client/private/src/echo_client_activator.c Mon Sep 29
06:58:59 2014
@@ -41,7 +41,6 @@ celix_status_t bundleActivator_create(bu
 	struct echoActivator * act = malloc(sizeof(*act));
 	act->client = NULL;
 	act->tracker = NULL;
-
 	*userData = act;
 
 	return CELIX_SUCCESS;
@@ -50,15 +49,14 @@ celix_status_t bundleActivator_create(bu
 celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
 	struct echoActivator * act = (struct echoActivator *) userData;
 
-	apr_pool_t *pool = NULL;
 	service_tracker_pt tracker = NULL;
 	echo_client_pt client = NULL;
 
-	bundleContext_getMemoryPool(context, &pool);
-	serviceTracker_create(pool, context, ECHO_SERVICE_NAME, NULL, &tracker);
+	serviceTracker_create(context, ECHO_SERVICE_NAME, NULL, &tracker);
+
 	act->tracker = tracker;
 
-	client = echoClient_create(tracker, pool);
+	client = echoClient_create(tracker);
 	act->client = client;
 
 	echoClient_start(act->client);

Modified: celix/trunk/examples/echo_service/server/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/trunk/examples/echo_service/server/CMakeLists.txt?rev=1628128&r1=1628127&r2=1628128&view=diff
==============================================================================
--- celix/trunk/examples/echo_service/server/CMakeLists.txt (original)
+++ celix/trunk/examples/echo_service/server/CMakeLists.txt Mon Sep 29 06:58:59 2014
@@ -15,6 +15,10 @@
 # specific language governing permissions and limitations
 # under the License.
 
+SET(BUNDLE_SYMBOLICNAME "apache_celix_examples_echo_server")
+SET(BUNDLE_VERSION "0.0.1")
+SET(BUNDLE_NAME "Apache Celix Echo Server")
+
 bundle(echo_server SOURCES 
 	private/src/echo_server_activator 
 	private/src/echo_server



Mime
View raw message