More diag logging, move WS_PRIVATE into the WS_CONNINFO

This commit is contained in:
Ron Pedde 2003-11-20 21:58:22 +00:00
parent 14a508bc34
commit 938d54b055
7 changed files with 39 additions and 44 deletions

View File

@ -351,6 +351,8 @@ int daap_serialize(DAAP_BLOCK *root, int fd, int gzip) {
}
free(uncompressed);
}
DPRINTF(ERR_DEBUG,"Finished serializing\n");
return 0;
}
@ -400,8 +402,12 @@ int daap_free(DAAP_BLOCK *root) {
if(!root)
return;
DPRINTF(ERR_DEBUG,"Freeing %c%c%c%c\n",root->tag[0],root->tag[1],
root->tag[2],root->tag[3]);
if((root->size) && (root->free))
free(root->value);
free(root->value); /* otherwise, static value */
daap_free(root->children);
daap_free(root->next);
free(root);

View File

@ -218,7 +218,7 @@ DAAP_BLOCK *daap_response_songlist(void) {
DPRINTF(ERR_DEBUG,"Preparing to send db items\n");
henum=db_enum_begin();
if(!henum) {
if((!henum) && (db_get_song_count())) {
DPRINTF(ERR_DEBUG,"Can't get enum handle\n");
return NULL;
}

View File

@ -229,6 +229,8 @@ void daap_handler(WS_CONNINFO *pwsc) {
}
}
DPRINTF(ERR_DEBUG,"Finished serving DAAP response\n");
return;
}
@ -255,7 +257,7 @@ int main(int argc, char *argv[]) {
WSCONFIG ws_config;
WSHANDLE server;
pid_t rendezvous_pid;
int use_mdns=1;
int use_mdns=0;
ENUMHANDLE handle;
MP3FILE *pmp3;

View File

@ -1,4 +1,5 @@
web_root ../admin-root
port 3689
admin_pw secret
mp3_dir mp3/Type O Negative
mp3_dir mp3
servername Ron's Secret Stash

View File

@ -73,6 +73,9 @@
Change History (most recent first):
$Log$
Revision 1.4 2003/11/20 21:58:22 ron
More diag logging, move WS_PRIVATE into the WS_CONNINFO
Revision 1.3 2003/11/17 16:40:09 ron
add support for named db
@ -295,7 +298,7 @@ enum {
kDefaultPortNumber = 80
};
static mDNSBool gAvoidPort53 = mDNSfalse;
static mDNSBool gAvoidPort53 = mDNStrue;
static const char *gRichTextHostName = "";
static const char *gServiceType = kDefaultServiceType;
static mDNSu8 gServiceText[sizeof(RDataBody)];

View File

@ -69,11 +69,6 @@ typedef struct tag_ws_private {
pthread_t server_tid;
} WS_PRIVATE;
typedef struct tag_ws_dispatchinfo {
WS_PRIVATE *pwsp;
WS_CONNINFO *pwsc;
} WS_DISPATCHINFO;
/*
* Forwards
*/
@ -226,7 +221,6 @@ void *ws_mainthread(void *arg) {
int fd;
int err;
WS_PRIVATE *pwsp = (WS_PRIVATE*)arg;
WS_DISPATCHINFO *pwsd;
WS_CONNINFO *pwsc;
pthread_t tid;
char hostname[MAX_HOSTNAME];
@ -250,20 +244,11 @@ void *ws_mainthread(void *arg) {
pwsc->hostname=strdup(hostname);
pwsc->fd=fd;
pwsc->pwsp = pwsp;
/* Spawn off a dispatcher to decide what to do with
* the request
*/
pwsd=(WS_DISPATCHINFO*)malloc(sizeof(WS_DISPATCHINFO));
if(!pwsd) {
/* keep on trucking until we crash bigger */
pwsc->error=EINVAL;
DPRINTF(ERR_FATAL,"Error: %s\n",strerror(errno));
free(pwsd);
ws_close(pwsc);
} else {
pwsd->pwsp=pwsp;
pwsd->pwsc=pwsc;
/* don't really care if it locks or not */
ws_lock_unsafe();
@ -272,17 +257,15 @@ void *ws_mainthread(void *arg) {
ws_unlock_unsafe();
/* now, throw off a dispatch thread */
if(err=pthread_create(&tid,NULL,ws_dispatcher,(void*)pwsd)) {
if(err=pthread_create(&tid,NULL,ws_dispatcher,(void*)pwsc)) {
pwsc->error=err;
DPRINTF(ERR_WARN,"Could not spawn thread: %s\n",strerror(err));
free(pwsd);
ws_close(pwsc);
}
pthread_detach(tid);
}
}
}
/*
@ -514,9 +497,8 @@ int ws_getgetvars(WS_CONNINFO *pwsc, char *string) {
* then decides what function should service the request
*/
void *ws_dispatcher(void *arg) {
WS_DISPATCHINFO *pwsd=(WS_DISPATCHINFO *)arg;
WS_PRIVATE *pwsp=pwsd->pwsp;
WS_CONNINFO *pwsc=pwsd->pwsc;
WS_CONNINFO *pwsc=(WS_CONNINFO*)arg;
WS_PRIVATE *pwsp=pwsc->pwsp;
char buffer[MAX_LINEBUFFER];
char *buffp;
char *first;
@ -532,8 +514,6 @@ void *ws_dispatcher(void *arg) {
void (*req_handler)(WS_CONNINFO*);
int(*auth_handler)(char *, char *);
free(pwsd);
DPRINTF(ERR_DEBUG,"Thread %d: Connection from %s\n",pwsc->threadno,
pwsc->hostname);

View File

@ -33,6 +33,9 @@
* Typedefs
*/
typedef void* WSHANDLE;
typedef struct tag_wsconfig {
char *web_root;
char *id;
@ -46,6 +49,7 @@ typedef struct tag_arglist {
} ARGLIST;
typedef struct tag_ws_conninfo {
WSHANDLE pwsp;
int threadno;
int error;
int fd;
@ -58,8 +62,6 @@ typedef struct tag_ws_conninfo {
ARGLIST request_vars;
} WS_CONNINFO;
typedef void* WSHANDLE;
/*
* Externs
*/
@ -81,4 +83,5 @@ extern int ws_addresponseheader(WS_CONNINFO *pwsc, char *header, char *fmt, ...)
extern int ws_writefd(WS_CONNINFO *pwsc, char *fmt, ...);
extern char *ws_getvar(WS_CONNINFO *pwsc, char *var);
extern int ws_testrequestheader(WS_CONNINFO *pwsc, char *header, char *value);
#endif /* _WEBSERVER_H_ */