mirror of
https://github.com/outbackdingo/parodus.git
synced 2026-01-28 18:20:04 +00:00
Adding a generic routine to start threads. White space change in connection.c
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
set(SOURCES main.c wss_mgr.c mutex.c networking.c nopoll_helpers.c
|
||||
string_helpers.c time.c config.c connection.c)
|
||||
string_helpers.c time.c config.c connection.c spin_thread.c)
|
||||
|
||||
add_executable(parodus ${SOURCES})
|
||||
|
||||
|
||||
@@ -345,18 +345,19 @@ char createNopollConnection(noPollCtx *ctx)
|
||||
}
|
||||
ParodusPrint("webpaProtocol is %s\n", webpaProtocol);
|
||||
|
||||
struct data meta_pack[METADATA_COUNT] = {{"hw-model", modelName},
|
||||
{"hw-serial-number", get_parodus_cfg()->hw_serial_number},
|
||||
{"hw-manufacturer", manufacturer},
|
||||
{"hw-mac", get_parodus_cfg()->hw_mac},
|
||||
{"hw_last_reboot_reason", reboot_reason},
|
||||
{"fw-name", firmwareVersion},
|
||||
{"boot_time", boot_time},
|
||||
{"webpa-last-reconnect-reason",reconnect_reason},
|
||||
{"webpa_protocol",webpaProtocol},
|
||||
{"webpa_uuid",get_parodus_cfg()->webpa_uuid},
|
||||
{"webpa_interface_used", get_parodus_cfg()->webpa_interface_used}
|
||||
};
|
||||
struct data meta_pack[METADATA_COUNT] = {
|
||||
{"hw-model", modelName},
|
||||
{"hw-serial-number", get_parodus_cfg()->hw_serial_number},
|
||||
{"hw-manufacturer", manufacturer},
|
||||
{"hw-mac", get_parodus_cfg()->hw_mac},
|
||||
{"hw_last_reboot_reason", reboot_reason},
|
||||
{"fw-name", firmwareVersion},
|
||||
{"boot_time", boot_time},
|
||||
{"webpa-last-reconnect-reason", reconnect_reason},
|
||||
{"webpa_protocol",webpaProtocol},
|
||||
{"webpa_uuid",get_parodus_cfg()->webpa_uuid},
|
||||
{"webpa_interface_used", get_parodus_cfg()->webpa_interface_used}
|
||||
};
|
||||
|
||||
const data_t metapack = {METADATA_COUNT, meta_pack};
|
||||
|
||||
|
||||
26
src/spin_thread.c
Normal file
26
src/spin_thread.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include "spin_thread.h"
|
||||
#include "parodus_log.h"
|
||||
|
||||
void StartThread(void *(*start_routine) (void *))
|
||||
{
|
||||
int err = 0;
|
||||
pthread_t threadId;
|
||||
|
||||
err = pthread_create(&threadId, NULL, start_routine, NULL);
|
||||
if (err != 0)
|
||||
{
|
||||
ParodusError("Error creating thread :[%s]\n", strerror(err));
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ParodusPrint("Thread created Successfully %d\n", (int ) threadId);
|
||||
}
|
||||
}
|
||||
|
||||
17
src/spin_thread.h
Normal file
17
src/spin_thread.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef _SPIN_THREAD_H_
|
||||
#define _SPIN_THREAD_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void StartThread(void *(*start_routine) (void *));
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -54,7 +54,8 @@ add_executable(simple simple.c
|
||||
../src/mutex.c
|
||||
../src/time.c
|
||||
../src/config.c
|
||||
../src/connection.c)
|
||||
../src/connection.c
|
||||
../src/spin_thread.c)
|
||||
|
||||
target_link_libraries (simple ${PARODUS_COMMON_LIBS} gcov -lnopoll -lnanomsg -lrt )
|
||||
endif (NOT EXCLUDE_SIMPLE)
|
||||
|
||||
Reference in New Issue
Block a user