mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-24 13:13:17 -05:00
More diag logging, move WS_PRIVATE into the WS_CONNINFO
This commit is contained in:
parent
14a508bc34
commit
938d54b055
@ -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;
|
||||
|
||||
if((root->size)&&(root->free))
|
||||
free(root->value);
|
||||
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); /* otherwise, static value */
|
||||
|
||||
daap_free(root->children);
|
||||
daap_free(root->next);
|
||||
free(root);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)];
|
||||
|
@ -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,37 +244,26 @@ 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);
|
||||
|
||||
/* don't really care if it locks or not */
|
||||
ws_lock_unsafe();
|
||||
pwsc->threadno=pwsp->threadno;
|
||||
pwsp->threadno++;
|
||||
ws_unlock_unsafe();
|
||||
|
||||
/* now, throw off a dispatch thread */
|
||||
if(err=pthread_create(&tid,NULL,ws_dispatcher,(void*)pwsc)) {
|
||||
pwsc->error=err;
|
||||
DPRINTF(ERR_WARN,"Could not spawn thread: %s\n",strerror(err));
|
||||
ws_close(pwsc);
|
||||
} else {
|
||||
pwsd->pwsp=pwsp;
|
||||
pwsd->pwsc=pwsc;
|
||||
|
||||
/* don't really care if it locks or not */
|
||||
ws_lock_unsafe();
|
||||
pwsc->threadno=pwsp->threadno;
|
||||
pwsp->threadno++;
|
||||
ws_unlock_unsafe();
|
||||
|
||||
/* now, throw off a dispatch thread */
|
||||
if(err=pthread_create(&tid,NULL,ws_dispatcher,(void*)pwsd)) {
|
||||
pwsc->error=err;
|
||||
DPRINTF(ERR_WARN,"Could not spawn thread: %s\n",strerror(err));
|
||||
free(pwsd);
|
||||
ws_close(pwsc);
|
||||
}
|
||||
|
||||
pthread_detach(tid);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -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_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user