Skip to content
Snippets Groups Projects
Commit bd15a8c2 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Merge branch 'sip_dev'

parents b4e80f65 b3898cc9
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,7 @@ typedef short int16; ...@@ -35,7 +35,7 @@ typedef short int16;
#define ASSERT( expected , value) if( value == expected ) return SUCCESS; \ #define ASSERT( expected , value) if( value == expected ) return SUCCESS; \
else return 1; else return 1;
#define PIDFILE "sfl.pid"
#ifdef DATAFORMAT_IS_FLOAT #ifdef DATAFORMAT_IS_FLOAT
#define SFLDataFormat float32 #define SFLDataFormat float32
#define SFLDataFormatString "Float32" #define SFLDataFormatString "Float32"
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <libintl.h> #include <libintl.h>
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
#include <string>
//#include "config.h" //#include "config.h"
#include "global.h" #include "global.h"
...@@ -50,6 +50,43 @@ main (int argc, char **argv) { ...@@ -50,6 +50,43 @@ main (int argc, char **argv) {
printf(_("See http://www.sflphone.org/ for more information\n")); printf(_("See http://www.sflphone.org/ for more information\n"));
} else { } else {
FILE *fp;
char homepid[128];
unsigned int iPid = getpid();
char cPid[64], cOldPid[64];
sprintf(cPid,"%d", iPid);
sprintf(homepid, "%s/.%s/%s", HOMEDIR, PROGDIR, PIDFILE);
if( (fp = fopen(homepid,"r")) == NULL ){
//PID file doesn't exists, create and write pid in it
if( (fp = fopen(homepid,"w")) == NULL ){
fprintf(stderr, _("Creating PID file %s failed. Exited.\n"), homepid);
exit(-1);
} else {
fputs(cPid , fp );
fclose( fp );
}
} else {
// PID file exists. Check the former process still alive or not. If alive, kill it and start a new one.
fgets( cOldPid, 64, fp );
fclose(fp);
if (kill(atoi(cOldPid), 0) == SUCCESS) {
fprintf(stderr, _("There is already a sflphoned daemon running in the system. Starting Failed.\n"));
exit(-1);
} else {
if( (fp = fopen(homepid,"w")) == NULL ){
fprintf(stderr, _("Writing to PID file %s failed. Exited.\n"), homepid);
exit(-1);
} else {
fputs(cPid , fp );
fclose( fp );
}
}
}
int sessionPort = 0; int sessionPort = 0;
if (argc == 2) { if (argc == 2) {
char* ptrPort = strstr(argv[1], "--port="); char* ptrPort = strstr(argv[1], "--port=");
......
...@@ -426,7 +426,7 @@ bool UserAgent::addAccount(AccountID id, pjsip_regc **regc2, const std::string& ...@@ -426,7 +426,7 @@ bool UserAgent::addAccount(AccountID id, pjsip_regc **regc2, const std::string&
status = pjsip_regc_send(regc, tdata); status = pjsip_regc_send(regc, tdata);
if (status != PJ_SUCCESS) { if (status != PJ_SUCCESS) {
_debug("UserAgent: Unable to send regc request.\n"); _debug("UserAgent: Unable to send regc request.\n");
pj_mutex_unlock(_mutex); //pj_mutex_unlock(_mutex);
return false; return false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment