curl-library
Some errors (fd=0) with socket_callback.
Date: Sun, 14 Oct 2012 19:11:47 +0200
Hi,
I'm getting some errors when reading a directory:
fuse-workspace[3124]: OPENDIR
fuse-workspace[3124]: determine_fuse_path, name: kernel
fuse-workspace[3124]: determine_fuse_path, relpath 18 lenpath 35
fusepath FTP/ftp.kernel.org/pub/linux/kernel
Oct 14 18:25:14 asus20110414.bononline.nl fuse-workspace[3124]: ftp_direxpired
fuse-workspace[3124]: opendir_ftp: set path to
ftp://ftp.kernel.org/pub/linux/kernel/
fuse-workspace[3124]: multi_timer_cb: received timeout 1
fuse-workspace[3124]: set_timerentry
fuse-workspace[3124]: insert_timerentry: insert 1350231914.279139618
fuse-workspace[3124]: insert_timerentry: first is changed: reset timer
fuse-workspace[3124]: set_timer: set at 1350231914.279139618 on fd 7
fuse-workspace[3124]: opendir_ftp: return (0)
fuse-workspace[3124]: opendir, return 0
fuse-workspace[3124]: mainloop: number of fd's: 1
fuse-workspace[3124]: eventloop: got a timer event, expirations 1
fuse-workspace[3124]: run_expired_timerentry
fuse-workspace[3124]: remove_timerentry_from_list
fuse-workspace[3124]: run_expired_timerentry: A
fuse-workspace[3124]: mainloop: number of fd's: 1
fuse-workspace[3124]: socket_callback: called with fd 17, what 1
fuse-workspace[3124]: READDIR
fuse-workspace[3124]: lookup_ftp_manager
fuse-workspace[3124]: add_to_epoll: add fd 17
fuse-workspace[3124]: socket_callback: return 0
fuse-workspace[3124]: ftp_readdir
fuse-workspace[3124]: mainloop: number of fd's: 1
fuse-workspace[3124]: socket_callback: called with fd 17, what 4
fuse-workspace[3124]: event_callback: events 1, fd 17, action 1
fuse-workspace[3124]: socket_callback: remove 17 from eventloop
fuse-workspace[3124]: socket_callback: called with fd 17, what 4
fuse-workspace[3124]: socket_callback: return 0
fuse-workspace[3124]: socket_callback: remove 17 from eventloop
fuse-workspace[3124]: socket_callback: called with fd 0, what 2
fuse-workspace[3124]: socket_callback: return 0
fuse-workspace[3124]: lookup_ftp_manager
fuse-workspace[3124]: socket_callback: called with fd 0, what 2
fuse-workspace[3124]: socket_callback: fd zero
fuse-workspace[3124]: lookup_ftp_manager
fuse-workspace[3124]: socket_callback: return -5
fuse-workspace[3124]: socket_callback: fd zero
fuse-workspace[3124]: socket_callback: return -5
fuse-workspace[3124]: multi_timer_cb: received timeout 4683
fuse-workspace[3124]: event_callback: curl_multi_socket_action return 0
fuse-workspace[3124]: curl_check_multi_info: remaining 1
fuse-workspace[3124]: set_timerentry
fuse-workspace[3124]: insert_timerentry: insert 1350231918.968476221
fuse-workspace[3124]: insert_timerentry: first is changed: reset timer
fuse-workspace[3124]: set_timer: set at 1350231918.968476221 on fd 7
fuse-workspace[3124]: curl_check_multi_info: remaining 1
fuse-workspace[3124]: run_expired_timerentry: A
fuse-workspace[3124]: run_expired_timerentry: B
fuse-workspace[3124]: set_timer: set at 1350231918.968476221 on fd 7
fuse-workspace[3124]: mainloop: number of fd's: 1
fuse-workspace[3124]: eventloop: got a timer event, expirations 1
fuse-workspace[3124]: run_expired_timerentry
fuse-workspace[3124]: remove_timerentry_from_list
fuse-workspace[3124]: run_expired_timerentry: A
fuse-workspace[3124]: socket_callback: called with fd 0, what 1
I've used the example hiperfifo.c to programm my fuse fs. See below for
how I've programmed the socket_callback and the calling from opendir.
AS you can see above, the socket_callback is called with fd=0. That's odd.
This should not happen. Someone has a clue?
Thanks in advance,
Stef Bon
In ftp_opendir the following happens:
ftp_readdirdata->ftp_manager=ftp_manager;
ftp_readdirdata->buff=NULL;
ftp_readdirdata->size=0;
ftp_readdirdata->lenread=0;
pthread_mutex_init(&ftp_readdirdata->mutex, NULL);
ftp_readdirdata->changed=0;
ftp_readdirdata->ready=0;
ftp_readdirdata->year=0;
ftp_readdirdata->uidset=0;
set_path_ftp_manager(ftp_manager, path, 1);
curl_easy_reset(ftp_manager->curlhandle);
curl_easy_setopt(ftp_manager->curlhandle,
CURLOPT_WRITEFUNCTION, readdir_data_from_peer);
curl_easy_setopt(ftp_manager->curlhandle, CURLOPT_WRITEDATA,
ftp_readdirdata);
logoutput("opendir_ftp: set path to %s", ftp_manager->path);
curl_easy_setopt(ftp_manager->curlhandle, CURLOPT_URL,
ftp_manager->path);
curl_easy_setopt(ftp_manager->curlhandle, CURLOPT_PRIVATE,
(void *) object);
res=curl_multi_add_handle(ftp_globalio.multi, ftp_manager->curlhandle);
with:
int socket_callback(CURL *easy, curl_socket_t curlfd, int what, void
*userdata, void *socketdata)
{
struct ftp_socket_struct *ftp_socket=(struct ftp_socket_struct *)
socketdata;
int nreturn=0;
logoutput("socket_callback: called with fd %i, what %i", (int)
curlfd, what);
if (what==CURL_POLL_REMOVE) {
struct workspace_object_struct *object;
struct epoll_extended_data_struct *epoll_xdata=NULL;
struct workspace_mount_struct *workspace_mount=NULL;
struct epoll_eventloop_struct *epoll_eventloop=NULL;
char *privatedata;
/* object on workspace mount pointing to ftp server resource
is stored in private */
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &privatedata);
/* char -> pointer is this possible ???? */
object=(struct workspace_object_struct *) privatedata;
epoll_xdata=&ftp_socket->epoll_xdata;
workspace_mount=object->workspace_mount;
epoll_eventloop=&workspace_mount->epoll_eventloop;
close(ftp_socket->curlfd);
ftp_socket->easy=NULL;
ftp_socket->curlfd=0;
logoutput("socket_callback: remove %i from eventloop", (int) curlfd);
remove_xdata_from_epoll(epoll_xdata, epoll_eventloop);
ftp_socket->addedtoepoll=0;
} else {
struct ftp_manager_struct *ftp_manager=NULL;
struct epoll_extended_data_struct *epoll_xdata=NULL;
struct workspace_object_struct *object;
struct workspace_mount_struct *workspace_mount=NULL;
struct epoll_eventloop_struct *epoll_eventloop=NULL;
uint32_t events=0;
char *privatedata;
/* what events: translate curl format into epoll format */
if (what & CURL_POLL_IN) events|=EPOLLIN;
if (what & CURL_POLL_OUT) events|=EPOLLOUT;
if (events==0) {
logoutput("socket_callback: no events");
nreturn=-EIO;
goto out;
}
/* object pointing to ftp server resource is stored in private */
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &privatedata);
/* char -> pointer is this possible ???? */
object=(struct workspace_object_struct *) privatedata;
ftp_manager=lookup_ftp_manager(object->resource);
/* when new: the ftp_socket does not exist yet
*/
if ( ! ftp_socket) {
if ( curlfd==0 ) {
logoutput("socket_callback: fd zero");
nreturn=-EIO;
goto out;
}
ftp_socket=get_ftp_socket(ftp_manager);
if (ftp_socket) {
ftp_socket->easy=easy;
ftp_socket->curlfd=curlfd;
ftp_socket->addedtoepoll=0;
} else {
goto out;
}
}
epoll_xdata=&ftp_socket->epoll_xdata;
workspace_mount=object->workspace_mount;
epoll_eventloop=&workspace_mount->epoll_eventloop;
if (ftp_socket->addedtoepoll==1) {
/* is already added to the eventloop, only a change */
modify_xdata(epoll_xdata, events, epoll_eventloop);
} else {
add_xdata_to_list(epoll_xdata, epoll_eventloop);
add_to_epoll(curlfd, events, TYPE_FD_SOCKET,
event_callback, (void *) ftp_socket, epoll_xdata, epoll_eventloop);
ftp_socket->addedtoepoll=1;
}
curl_multi_assign(ftp_globalio.multi, curlfd, (void *) ftp_socket);
}
out:
logoutput("socket_callback: return %i", nreturn);
return nreturn;
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-10-14