meshlink_errno = MESHLINK_EINVAL;
return false;
}
- pthread_mutex_lock(&(mesh->mesh_mutex));
logger(mesh, MESHLINK_DEBUG, "meshlink_start called\n");
+ pthread_mutex_lock(&(mesh->mesh_mutex));
+
+ if(mesh->threadstarted) {
+ logger(mesh, MESHLINK_DEBUG, "thread was already running\n");
+ pthread_mutex_unlock(&(mesh->mesh_mutex));
+ return true;
+ }
+
if(mesh->listen_socket[0].tcp.fd < 0) {
logger(mesh, MESHLINK_ERROR, "Listening socket not open\n");
meshlink_errno = MESHLINK_ENETWORK;