Socket config, and no need to awaken_sel()
This commit is contained in:
parent
2574cfd9ed
commit
8d2903d415
6 changed files with 30 additions and 5 deletions
|
@ -18,6 +18,7 @@ extern pthread_mutex_t cfmx;
|
|||
main return MAIN;
|
||||
loglevel pthread_mutex_lock(&cfmx); cf.loglevels = LL_CRITICAL|LL_FATAL; pthread_mutex_unlock(&cfmx); return LLEVEL;
|
||||
database return DB;
|
||||
socket return SOCK;
|
||||
all yylval.number = LL_ALL; return LNUML;
|
||||
debug yylval.number = LL_DEBUG; return LNUML;
|
||||
info yylval.number = LL_INFO; return LNUML;
|
||||
|
|
|
@ -34,7 +34,7 @@ int yywrap(void)
|
|||
}
|
||||
%}
|
||||
%token NOTIFY OBRACE CBRACE SCOLON QUOTE MODDEV MAIN LLEVEL OR
|
||||
%token FILTERS ACTION NAME PHNUM FILTER FLAGS DB
|
||||
%token FILTERS ACTION NAME PHNUM FILTER FLAGS DB SOCK
|
||||
/* HANGUP IGNOREIT PLAY RECORD */
|
||||
%token <number> LNUML ACTN FLAG
|
||||
%token <string> IPADDR PATH REGEX FNAME
|
||||
|
@ -66,6 +66,8 @@ directive:
|
|||
loglevel
|
||||
|
|
||||
database
|
||||
|
|
||||
socket
|
||||
;
|
||||
notify:
|
||||
NOTIFY iplist
|
||||
|
@ -84,6 +86,18 @@ ipadr:
|
|||
addtoaddrs($1);
|
||||
}
|
||||
;
|
||||
socket:
|
||||
SOCK sockpath
|
||||
;
|
||||
sockpath:
|
||||
QUOTE PATH QUOTE
|
||||
{
|
||||
lprintf(debug, "Socket path == %s\n", $2);
|
||||
pthread_mutex_lock(&cfmx);
|
||||
cf.sockfile = $2;
|
||||
pthread_mutex_unlock(&cfmx);
|
||||
}
|
||||
;
|
||||
database:
|
||||
DB dbpath
|
||||
;
|
||||
|
|
|
@ -30,8 +30,10 @@ void shutd(whatdone)
|
|||
int whatdone;
|
||||
{
|
||||
lprintf(fatal, "phoned shutting down (th %s)...\n", pthread_equal(pthread_self(), networkth) ? "network" : (pthread_equal(pthread_self(), modemth) ? "modem" : "other/main"));
|
||||
awaken_sel();
|
||||
unlink(SOCKETFILE);
|
||||
/* awaken_sel(); */
|
||||
pthread_mutex_lock(&cfmx);
|
||||
unlink(cf.sockfile);
|
||||
pthread_mutex_unlock(&cfmx);
|
||||
if(whatdone & WD_MODEM) modem_wake();
|
||||
flush_lists();
|
||||
flush_logins();
|
||||
|
|
|
@ -43,6 +43,7 @@ int main(argc, argv)
|
|||
cf.cfile = CONFIGFILE;
|
||||
cf.dbfile = DBFILE;
|
||||
cf.logfile = LOGFILE;
|
||||
cf.sockfile = SOCKETFILE;
|
||||
#define OPTSTRING "dhc:l:"
|
||||
while((c = getopt(argc, argv, OPTSTRING)) != -1)
|
||||
switch(c) {
|
||||
|
|
|
@ -2,6 +2,7 @@ main {
|
|||
modemdev "/dev/cuaa2";
|
||||
loglevel all;
|
||||
database "./phoned.db";
|
||||
socket "/tmp/phoned1.sock";
|
||||
};
|
||||
filters {
|
||||
filter test1 {
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
|
||||
extern pthread_mutex_t modemmx;
|
||||
extern pthread_mutex_t buffermx;
|
||||
extern pthread_mutex_t cfmx;
|
||||
extern struct conf cf;
|
||||
pthread_t networkth;
|
||||
int selpipes[2];
|
||||
pthread_mutex_t spipsmx;
|
||||
|
@ -97,7 +99,9 @@ void *network(b)
|
|||
pthread_mutex_lock(&spipsmx);
|
||||
pipe(selpipes);
|
||||
pthread_mutex_unlock(&spipsmx);
|
||||
strcpy(it.sun_path, SOCKETFILE);
|
||||
pthread_mutex_lock(&cfmx);
|
||||
strcpy(it.sun_path, cf.sockfile);
|
||||
pthread_mutex_unlock(&cfmx);
|
||||
it.sun_family = AF_LOCAL;
|
||||
if(bind(s, (struct sockaddr *)&it, 1 + strlen(it.sun_path) +
|
||||
sizeof(it.sun_family)) == -1) {
|
||||
|
@ -146,6 +150,8 @@ void *network(b)
|
|||
if(*cbuf != 0) break;
|
||||
}
|
||||
close(s);
|
||||
unlink(SOCKETFILE);
|
||||
pthread_mutex_lock(&cfmx);
|
||||
unlink(cf.sockfile);
|
||||
pthread_mutex_unlock(&cfmx);
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue