title: dispatch_semaphore_wait blocked my network request callback
body: <pre><code> -(void)init{
          self.sema = dispatch_semaphore_create(1)
      }
  
  -(void)main{
     //sending one message is fine
     [self preSendMessage:@"hi"];
  
     //deadlock happen when sending multiple msg in a short time.
     for(int i = 0; i &lt; 10; i++){
         [self preSendMessage:@"yo"];
     }
  
  }
  
  - (void)preSendMessage:(NSString*)msg
  {
  
      dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  
          dispatch_semaphore_wait(self.sema, DISPATCH_TIME_FOREVER);
  
  
          RACSignal* signal = [self sendMessage:msg];
  
          @weakify(self);
  
          [signal subscribeNext:^(id x) {
          } error:^(NSError *error) {
              @strongify(self);
              dispatch_semaphore_signal(self.sema);
          } completed:^{
              @strongify(self);
              dispatch_semaphore_signal(self.sema);
          }];
      });
  }
  </code></pre>
  
  <p>Some informations:</p>
  
  <ul>
  <li><p>In sendMessage function, I am using AFNetworking.</p></li>
  <li><p>When I remove the semaphore logic, it works fine, I need this because need to control the sequence of sending msgs.</p></li>
  <li><p>[Update] my semaphore is init with value 1, so It would run at the first time</p></li>
  <li><p>My Target is to ensure the code inside preSendMessage execute when the previous one is completed/error</p></li>
  </ul>