add electricfence to detect some heap trouncing, fix some update handling bugs, make run on linux. Still some linux issues
This commit is contained in:
parent
c2dcb67bc7
commit
3805df1ee8
|
@ -11,7 +11,7 @@ AC_PROG_CC
|
|||
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
AC_ARG_ENABLE(debug,Enable debugging features,CPPFLAGS="$CPPFLAGS -DDEBUG -g")
|
||||
AC_ARG_ENABLE(debug,Enable debugging features,CPPFLAGS="$CPPFLAGS -DDEBUG -g";LDFLAGS="$LDFLAGS -lefence")
|
||||
|
||||
dnl Darwin's stupid cpp preprocessor....
|
||||
echo Host type is $host
|
||||
|
|
|
@ -212,6 +212,7 @@ DAAP_BLOCK *daap_add_data(DAAP_BLOCK *parent, char *tag,
|
|||
DAAP_BLOCK *daap_add_string(DAAP_BLOCK *parent, char *tag, char *value) {
|
||||
char *newvalue;
|
||||
|
||||
if(value) {
|
||||
if(strlen(value) > 4) {
|
||||
newvalue=strdup(value);
|
||||
|
||||
|
@ -222,6 +223,8 @@ DAAP_BLOCK *daap_add_string(DAAP_BLOCK *parent, char *tag, char *value) {
|
|||
}
|
||||
return daap_add_formatted(parent,tag,strlen(value),value);
|
||||
}
|
||||
return daap_add_formatted(parent,tag,0,"");
|
||||
}
|
||||
|
||||
/*
|
||||
* daap_add_empty
|
||||
|
|
|
@ -47,6 +47,7 @@ MP3RECORD db_root;
|
|||
int db_version_no;
|
||||
int db_update_mode=0;
|
||||
int db_song_count;
|
||||
int db_song_id;
|
||||
pthread_rwlock_t db_rwlock; /* OSX doesn't have PTHREAD_RWLOCK_INITIALIZER */
|
||||
pthread_once_t db_initlock=PTHREAD_ONCE_INIT;
|
||||
/*
|
||||
|
@ -89,6 +90,7 @@ int db_init(char *parameters) {
|
|||
db_root.next=NULL;
|
||||
db_version_no=1;
|
||||
db_song_count=0;
|
||||
db_song_id=0;
|
||||
|
||||
return pthread_once(&db_initlock,db_init_once);
|
||||
}
|
||||
|
@ -192,6 +194,7 @@ int db_add(MP3FILE *mp3file) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
pnew->mp3file.id=db_song_id++;
|
||||
pnew->next=db_root.next;
|
||||
db_root.next=pnew;
|
||||
|
||||
|
|
|
@ -80,10 +80,10 @@ void daap_handler(WS_CONNINFO *pwsc) {
|
|||
} else if (!strcasecmp(pwsc->uri,"/login")) {
|
||||
root=daap_response_login();
|
||||
} else if (!strcasecmp(pwsc->uri,"/update")) {
|
||||
if(!ws_getvar(pwsc,"revision-number")) { /* first check */
|
||||
if(!ws_getvar(pwsc,"delta")) { /* first check */
|
||||
clientrev=db_version() - 1;
|
||||
} else {
|
||||
clientrev=atoi(ws_getvar(pwsc,"revision-number"));
|
||||
clientrev=atoi(ws_getvar(pwsc,"delta"));
|
||||
}
|
||||
root=daap_response_update(clientrev);
|
||||
} else if (!strcasecmp(pwsc->uri,"/databases")) {
|
||||
|
@ -309,12 +309,16 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
DPRINTF(ERR_DEBUG,"Initializing database\n");
|
||||
|
||||
/* Initialize the database before starting */
|
||||
if(db_init("none")) {
|
||||
perror("db_init");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
DPRINTF(ERR_DEBUG,"Scanning MP3s\n");
|
||||
|
||||
if(scan_init(config.mp3dir)) {
|
||||
perror("scan_init");
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <sys/types.h>
|
||||
|
||||
#include "db-memory.h"
|
||||
#include "err.h"
|
||||
#include "mp3-scanner.h"
|
||||
|
||||
/*
|
||||
|
@ -83,6 +84,7 @@ int scan_foreground(char *path) {
|
|||
}
|
||||
|
||||
while(1) {
|
||||
pde=&de;
|
||||
err=readdir_r(current_dir,&de,&pde);
|
||||
if(err == -1) {
|
||||
err=errno;
|
||||
|
@ -96,8 +98,9 @@ int scan_foreground(char *path) {
|
|||
|
||||
/* process the file */
|
||||
if(strlen(de.d_name) > 4) {
|
||||
if(strcasecmp(".mp3",de.d_name[strlen(de.d_name) - 4]) == 0) {
|
||||
if(strcasecmp(".mp3",(char*)&de.d_name[strlen(de.d_name) - 4]) == 0) {
|
||||
/* we found an mp3 file */
|
||||
DPRINTF(ERR_DEBUG,"Found mp3: %s\n",de.d_name);
|
||||
sprintf(mp3_path,"%s/%s",path,de.d_name);
|
||||
memset((void*)&mp3file,0,sizeof(mp3file));
|
||||
mp3file.path=mp3_path;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
web_root /Users/ron/Documents/School/cs4953 - Concurrency/mt-daapd/admin-root
|
||||
web_root /home/ron/working/mt-daapd/admin-root
|
||||
port 3689
|
||||
admin_password secret
|
||||
mp3_dir /Users/ron/Music/iTunes/iTunes Music/Poe/Hello
|
||||
mp3_dir /home/ron/mp3
|
||||
|
|
|
@ -1014,7 +1014,7 @@ char *ws_urldecode(char *string) {
|
|||
char *src,*dst;
|
||||
int val;
|
||||
|
||||
pnew=(char*)malloc(strlen(string));
|
||||
pnew=(char*)malloc(strlen(string)+1);
|
||||
if(!pnew)
|
||||
return NULL;
|
||||
|
||||
|
|
Loading…
Reference in New Issue