Broken debugging stuff for no quitting
This commit is contained in:
parent
d254331dae
commit
38dbccee02
@ -3,7 +3,7 @@
|
||||
* (C)2005, Dan Ponte
|
||||
* BSDL w/ advert.
|
||||
*/
|
||||
/* $Amigan: phoned/include/phoned.h,v 1.18 2005/06/19 01:24:15 dcp1990 Exp $ */
|
||||
/* $Amigan: phoned/include/phoned.h,v 1.19 2005/06/19 02:47:43 dcp1990 Exp $ */
|
||||
#include <pcre.h> /* fugly, I know... */
|
||||
#define VERSION "0.1"
|
||||
#define LOGFILE "/var/log/phoned.log"
|
||||
@ -168,6 +168,8 @@ short db_init(char* dbfilename);
|
||||
short db_destroy(void);
|
||||
short db_add_call(cid_t* c, time_t t);
|
||||
void cid_handle(cid_t *c);
|
||||
void awaken_sel(void);
|
||||
void modem_wake(void);
|
||||
/* old stuff...
|
||||
void modem_pickup(void);
|
||||
void modem_hangup(void);
|
||||
|
@ -28,14 +28,16 @@ void shutd(whatdone)
|
||||
{
|
||||
lprintf(fatal, "phoned shutting down...\n");
|
||||
pthread_mutex_lock(&cfmx);
|
||||
lprintf(info, "got cf lock");
|
||||
if(whatdone & WD_MODEM) close_modem(cf.modemdev);
|
||||
pthread_mutex_unlock(&cfmx);
|
||||
flush_lists();
|
||||
free_condition(topcond, 0x1);
|
||||
pthread_mutex_lock(&logfmx);
|
||||
if(whatdone & WD_LOGS) fclose(logf);
|
||||
pthread_mutex_unlock(&logfmx);
|
||||
if(whatdone & WD_DBINIT) db_destroy();
|
||||
lprintf(info, "got log lock");
|
||||
if(whatdone & WD_LOGS) fclose(logf);
|
||||
unlink(SOCKETFILE);
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,12 @@ void stmod(str)
|
||||
pthread_mutex_unlock(&modemmx);
|
||||
}
|
||||
}
|
||||
void modem_wake(void)
|
||||
{
|
||||
pthread_mutex_lock(&mpipemx);
|
||||
write(modempipes[1], "D", 1);
|
||||
pthread_mutex_unlock(&mpipemx);
|
||||
}
|
||||
void give_me_modem(str) /* warning: deprecated! */
|
||||
char *str;
|
||||
{
|
||||
@ -220,7 +226,9 @@ void *modem_io(k)
|
||||
}
|
||||
if(FD_ISSET(modempipes[0], &fds) != 0) {
|
||||
read(modempipes[0], cbuf, 1);
|
||||
pthread_cond_wait(&mpcond, &modemmx);
|
||||
if(*cbuf == 'G') pthread_cond_wait(&mpcond, &modemmx); else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
/* $Amigan: phoned/phoned/notify.c,v 1.5 2005/06/19 01:35:50 dcp1990 Exp $ */
|
||||
/* $Amigan: phoned/phoned/notify.c,v 1.6 2005/06/19 02:47:45 dcp1990 Exp $ */
|
||||
#include <fcntl.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
@ -87,7 +87,7 @@ int cid_notify(cid_t* c)
|
||||
char* msg;
|
||||
int s;
|
||||
struct sockaddr_in sin;
|
||||
char on = 0x1;
|
||||
int on = 0x1;
|
||||
addrsll_t *cur;
|
||||
len = strlen(c->number) + strlen(c->name) + 8 + 5 + 4;
|
||||
msg = malloc(len * sizeof(char));
|
||||
|
@ -32,17 +32,25 @@
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <phoned.h>
|
||||
|
||||
extern pthread_t networkth;
|
||||
void handsig(sig)
|
||||
int sig;
|
||||
{
|
||||
if(pthread_equal(pthread_self(), networkth)) {
|
||||
lprintf(info, "siamo spesa");
|
||||
return;
|
||||
}
|
||||
signal(sig, handsig);
|
||||
switch(sig) {
|
||||
case SIGINT:
|
||||
case SIGQUIT:
|
||||
case SIGTERM:
|
||||
lprintf(fatal, "Received signal %d, cleaning up...\n", sig);
|
||||
awaken_sel();
|
||||
lprintf(info, "woke up sel");
|
||||
modem_wake();
|
||||
lprintf(info, "woke up mod");
|
||||
shutd(0x1 | 0x2 | 0x4 | 0x10 | 0x20);
|
||||
exit(0);
|
||||
break;
|
||||
|
@ -50,6 +50,8 @@
|
||||
extern pthread_mutex_t modemmx;
|
||||
extern pthread_mutex_t buffermx;
|
||||
pthread_t networkth;
|
||||
int selpipes[2];
|
||||
pthread_mutex_t spipsmx;
|
||||
void *handclient(k)
|
||||
void* k;
|
||||
{
|
||||
@ -58,10 +60,25 @@ void *handclient(k)
|
||||
tf = fdopen(sk, "r+");
|
||||
begin_dialogue(tf, sk);
|
||||
fclose(tf);
|
||||
lprintf(info, "here");
|
||||
pthread_exit(NULL);
|
||||
lprintf(info, "there");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void clsck(sck)
|
||||
void *sck;
|
||||
{
|
||||
int s = (int)sck;
|
||||
close(s);
|
||||
}
|
||||
#endif
|
||||
void awaken_sel(void)
|
||||
{
|
||||
pthread_mutex_lock(&spipsmx);
|
||||
write(selpipes[1], "W", 1);
|
||||
pthread_mutex_unlock(&spipsmx);
|
||||
}
|
||||
void *network(b)
|
||||
void* b;
|
||||
{
|
||||
@ -78,6 +95,9 @@ void *network(b)
|
||||
shutd(0x1|0x2|0x4|0x10|0x20);
|
||||
exit(-1);
|
||||
}
|
||||
pthread_mutex_lock(&spipsmx);
|
||||
pipe(selpipes);
|
||||
pthread_mutex_unlock(&spipsmx);
|
||||
strcpy(it.sun_path, SOCKETFILE);
|
||||
it.sun_family = AF_LOCAL;
|
||||
if(bind(s, (struct sockaddr *)&it, 1 + strlen(it.sun_path) +
|
||||
@ -94,11 +114,13 @@ void *network(b)
|
||||
for(;;) {
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(s, &fds);
|
||||
switch(select(s + 1, &fds, NULL, NULL, NULL)) {
|
||||
FD_SET(selpipes[0], &fds);
|
||||
switch(select(selpipes[0] + 1, &fds, NULL, NULL, NULL)) { /* this had better be a cancellation point... */
|
||||
case -1:
|
||||
lprintf(error, "select: %s\n", strerror(errno));
|
||||
shutd(0x1|0x2|0x4|0x10|0x20);
|
||||
exit(-1);
|
||||
pthread_exit(NULL);
|
||||
return (void*)0;
|
||||
lprintf(error, "selet: \n");
|
||||
break;
|
||||
case 0:
|
||||
/* NOTREACHED */
|
||||
@ -120,10 +142,17 @@ void *network(b)
|
||||
,ilen);
|
||||
|
||||
}
|
||||
if(FD_ISSET(selpipes[0], &fds) != 0) {
|
||||
char tbuf[2];
|
||||
lprintf(info, "woken\n");
|
||||
read(selpipes[0], tbuf, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
lprintf(info, "still alive!");
|
||||
close(s);
|
||||
unlink(SOCKETFILE);
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user