Re: FSMountServerVolumeAsync() in multiple threads?
Re: FSMountServerVolumeAsync() in multiple threads?
- Subject: Re: FSMountServerVolumeAsync() in multiple threads?
- From: Matt DeFoor <email@hidden>
- Date: Wed, 12 Aug 2009 14:04:11 -0400
On Tue, Aug 11, 2009 at 11:51 PM, Kevin Elliott<email@hidden> wrote:
> I'd have to look into your code to know for certain what's going wrong, but
> your raising a few red flags.
>
> In particular, your spawning a new thread and then (from the sound of it)
> doing one FSMountServerVolumeAsync per thread. That sounds very odd. If
> your going to go to the trouble of creating a separate thread, why not just
> call FSMountServerVolumeSync?
When a volume mount is done via FSMountServerVolumeAsync() you have
the opportunity to cancel the volume operation (e.g. it is taking too
long and the user wants to cancel the volume mount). One reason for
using each call to FSMountServerVolumeAsync() in it's own thread is
that FSMountServerVolumeAsync() blocks for 120 seconds if the server
can't be contacted. It does this block and if there is an error, the
callback is not called. The following is a transcript of how it blocks
when there is no machine responding to the address of the server:
The following four lines show how FSMountServerVolumeAsync() does not
block when it can communicate with the server in question:
2009-08-12 13:29:40.043 MyApp[12036] FSMountServerVolumeAsync called
on main thread...
2009-08-12 13:29:40.281 MyApp [12036] CCVolumeMountCallback called on
main thread...
2009-08-12 13:29:40.283 MyApp [12036] CCVolumeMountCallback returned
from call on main thread...
2009-08-12 13:29:40.283 MyApp [12036] FSMountServerVolumeAsync
returned from call on main thread; Result = 0
The following two lines show how FSMountServerVolumeAsync() blocks
when the it cannot communicate with the server in question:
2009-08-12 13:29:40.283 MyApp [12036] FSMountServerVolumeAsync called
on main thread...
2009-08-12 13:30:54.938 MyApp [12036] FSMountServerVolumeAsync
returned from call on main thread; Result = -5016 (Server is not
responding.)
As you can see, there is a signficant delay from when the function is
called and to when it returns. The callback is not called. Either this
non-asynchronous behaviour is a bug, or I simply do not understand how
to make it stop blocking. In this test, it is running on the main
thread. It seems to me that I wouldn't have to manage the run loop in
this scenario. If FSMountServerVolumeAsync() did not block in this
situation, I wouldn't be trying to use it from other threads.
FSMountServerVolumeSync() exhibits the same blocking problem.
> Are you creating a runLoop in your thread for
> your callbacks to fire on?
I'm doing this little bit of work...it may not be correct or sufficient:
FSMountStatus status = 0;
OSStatus volumeOpStatus = 0;
OSStatus Result = 0;
FSVolumeRefNum mountedVolumeRefNum;
CCResource *r = NULL;
while (kAsyncMountComplete != status)
{
CFRunLoopRunInMode(CFSTR("MountMode"), 5.0, true);
Result = FSGetAsyncMountStatus(volumeOp, &status, &volumeOpStatus,
&mountedVolumeRefNum, (void *)r);
if (Result)
{
NSLog(@"Failed to get async mount status (%d).", Result);
break;
}
}
> Is the -50 error coming from
> FSMountServerVolumeAsync directly, or when your callback fires?
It is returned directly from FSMountServerVolumeAsync() and not when
the callback fires.
> You said
> this was working in one thread- why are you moving to multiple threads?
>
See the response to your first question.
Thanks,
Matt
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden