fix windows blocking socket issue, work around problem with temp update table not being seen by fetch thread during db update

This commit is contained in:
Ron Pedde 2007-10-24 05:44:35 +00:00
parent c8d09bc310
commit e842f38fce
2 changed files with 12 additions and 6 deletions

View File

@ -933,7 +933,8 @@ int db_sql_add(char **pe, MP3FILE *pmp3, int *id) {
insertid = db_sql_insert_id_fn();
if((db_sql_in_scan || db_sql_in_playlist_scan)&&(!db_sql_reload)) {
db_sql_exec_fn(NULL,E_FATAL,"insert into updated values (%d)",
/* fetch threads have different sqlite handle -- won't see the update table */
db_sql_exec_fn(NULL,E_DBG,"insert into updated values (%d)",
insertid);
}
@ -1564,7 +1565,7 @@ MP3FILE *db_sql_fetch_item(char **pe, int id) {
db_sql_dispose_row();
if ((db_sql_in_scan || db_sql_in_playlist_scan) && (!db_sql_reload)) {
db_sql_exec_fn(pe,E_FATAL,"INSERT INTO updated VALUES (%d)",id);
db_sql_exec_fn(pe,E_DBG,"INSERT INTO updated VALUES (%d)",id);
}
return pmp3;
@ -1614,7 +1615,7 @@ MP3FILE *db_sql_fetch_path(char **pe, char *path, int index) {
db_sql_dispose_row();
if ((db_sql_in_scan || db_sql_in_playlist_scan) && (!db_sql_reload)) {
db_sql_exec_fn(pe,E_FATAL,"INSERT INTO updated VALUES (%d)",pmp3->id);
db_sql_exec_fn(pe,E_DBG,"INSERT INTO updated VALUES (%d)",pmp3->id);
}
return pmp3;

View File

@ -370,7 +370,7 @@ int io_init(void) {
io_handler_list.next = NULL;
#ifdef WIN32
wVersionRequested = MAKEWORD(2,0);
wVersionRequested = MAKEWORD(2,2);
err = WSAStartup(wVersionRequested, &io_WSAData);
if(err) {
io_err_printf(IO_LOG_FATAL,"Could not initialize winsock\n");
@ -2309,14 +2309,19 @@ int io_socket_write(IO_PRIVHANDLE *phandle, unsigned char *buf,uint32_t *len) {
byteswritten = send(priv->fd, bufp, bytestowrite, 0);
}
io_err_printf(IO_LOG_DEBUG,"wrote %d bytes to socket %d\n",byteswritten,priv->fd);
io_err_printf(IO_LOG_SPAM,"wrote %d bytes to socket %d\n",byteswritten,priv->fd);
#ifdef WIN32
if(WSAGetLastError() == WSAEWOULDBLOCK) {
byteswritten = 0;
if(priv->hEvent) {
WSAEventSelect(priv->fd,(WSAEVENT)priv->hEvent,0);
}
blocking = 0;
if(ioctlsocket(priv->fd,FIONBIO,&blocking)) {
io_err_printf(IO_LOG_LOG,"Couldn't set socket to blocking\n");
io_err_printf(IO_LOG_LOG,"Couldn't set socket to blocking: %ld\n",WSAGetLastError());
}
}
#endif