+static int service_start(void)
+{
+ DEBUG("starting up..");
+
+ DEBUG("initializing event..");
+ temp_base = event_base_new();
+
+ DEBUG("opening socket..");
+
+ temp_sock = pinba_socket_open(service_address, service_port);
+
+ if (!temp_sock) {
+ service_cleanup();
+ return 1;
+ }
+
+ if (pthread_create(&temp_thrd, NULL, pinba_main, NULL)) {
+ service_cleanup();
+ return 1;
+ }
+
+ return 0;
+}
+
+static int service_stop (void)
+{
+ pthread_cancel(temp_thrd);
+ pthread_join(temp_thrd, NULL);
+ service_status=0;
+ DEBUG("terminating listen-loop..");
+
+ service_cleanup();
+
+ return 0;
+}
+
+static void service_config (const char *address, unsigned int port) /* {{{ */
+{
+ int need_restart = 0;
+
+ if (address && service_address && (strcmp(service_address, address) != 0))
+ {
+ strset (&service_address, address);
+ need_restart++;
+ }
+
+ if ((port > 0) && (port < 65536) && (service_port != port))
+ {
+ service_port=port;
+ need_restart++;
+ }
+
+ if(service_status && need_restart)
+ {
+ service_stop();
+ service_start();
+ }
+} /* }}} void service_config */
+