0004-bonjour-nullify-delegate-before-removing-service-fro.patch 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. From 2e71373c6d8f390376c679dfe4676c5068612b60 Mon Sep 17 00:00:00 2001
  2. From: Gleb Pinigin <gpinigin@gmail.com>
  3. Date: Thu, 1 Aug 2013 19:22:27 +0700
  4. Subject: [PATCH 4/4] bonjour: nullify delegate before removing service from
  5. current runloop
  6. ---
  7. Core/HTTPServer.m | 7 +++----
  8. 1 file changed, 3 insertions(+), 4 deletions(-)
  9. diff --git a/Core/HTTPServer.m b/Core/HTTPServer.m
  10. index 57384f7..5983121 100644
  11. --- a/Core/HTTPServer.m
  12. +++ b/Core/HTTPServer.m
  13. @@ -568,7 +568,7 @@ static const int httpLogLevel = HTTP_LOG_LEVEL_INFO; // | HTTP_LOG_FLAG_TRACE;
  14. if (type)
  15. {
  16. netService = [[NSNetService alloc] initWithDomain:domain type:type name:name port:[asyncSocket localPort]];
  17. - [netService setDelegate:self];
  18. + netService.delegate = self;
  19. NSNetService *theNetService = netService;
  20. NSData *txtRecordData = nil;
  21. @@ -576,8 +576,6 @@ static const int httpLogLevel = HTTP_LOG_LEVEL_INFO; // | HTTP_LOG_FLAG_TRACE;
  22. txtRecordData = [NSNetService dataFromTXTRecordDictionary:txtRecordDictionary];
  23. dispatch_block_t bonjourBlock = ^{
  24. -
  25. - [theNetService removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
  26. [theNetService scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
  27. [theNetService publish];
  28. @@ -603,10 +601,11 @@ static const int httpLogLevel = HTTP_LOG_LEVEL_INFO; // | HTTP_LOG_FLAG_TRACE;
  29. if (netService)
  30. {
  31. NSNetService *theNetService = netService;
  32. + netService.delegate = nil;
  33. dispatch_block_t bonjourBlock = ^{
  34. -
  35. [theNetService stop];
  36. + [theNetService removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
  37. };
  38. [[self class] performBonjourBlock:bonjourBlock];
  39. --
  40. 1.7.12.4 (Apple Git-37)