• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSPipe (NSFileHandle) writedata limit?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPipe (NSFileHandle) writedata limit?


  • Subject: Re: NSPipe (NSFileHandle) writedata limit?
  • From: Greg Guerin <email@hidden>
  • Date: Mon, 12 Apr 2010 09:09:42 -0700

McLaughlin, Michael P. wrote:

main --> subtask (main send data)

-(void)sendData:(void*)data numBytes:(NSUInteger)sz taskTag: (NSString*)tag
{
NSData *dataset = [NSData dataWithBytes:data length:sz];
NSNumber *num = [NSNumber numberWithUnsignedInteger:sz]; // NSUInteger
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: num,
@"size", nil];
[sendEnd writeData:dataset]; // Do NOT close the fileHandle!
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:tag
object:myID userInfo:dict];
}


That is, main
1) sends (via FileHandle and pipe) a known quantity of data to the subtask
and
2) tells it what sort of data are coming and how much.


All that stuff I just wrote?  Uh, never mind.

There's your deadlock right there.

You must send the notification with size and such BEFORE writing to the pipe. Otherwise the sender can become blocked, because the receiver doesn't know it should be reading anything.

If you'd been sending the size over the pipe, it would have been obvious. You have to tell the receiver how many bytes follow.

  -- GG

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSPipe (NSFileHandle) writedata limit?
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: NSPipe (NSFileHandle) writedata limit?
  • Next by Date: Re: IKImageView delegate
  • Previous by thread: Re: NSPipe (NSFileHandle) writedata limit?
  • Next by thread: Re: NSPipe (NSFileHandle) writedata limit?
  • Index(es):
    • Date
    • Thread