예제 #1
0
파일: Socket.cs 프로젝트: aaronfeng/manos
        private void StartSending()
        {
            if (current_write_op == null)
            {
                return;
            }
            bool cont = true;

            while (cont)
            {
                if (disabledsending)
                {
                    sending = false;
                    return;
                }
                cont = false;
                if (current_write_op.IsComplete)
                {
                    current_write_op.EndWrite(this);

                    if (write_ops.Count > 0)
                    {
                        IWriteOperation op = write_ops.Dequeue();
                        sending = false;
                        op.BeginWrite(this);
                        current_write_op = op;
                        current_write_op.HandleWrite(this);
                        lock (this)
                        {
                            if (!sending)
                            {
                                cont = true;
                            }
                        }
                    }
                    else
                    {
                        current_write_op = null;
                    }
                }
                else
                {
                    current_write_op.HandleWrite(this);
                    lock (this)
                    {
                        if (!sending)
                        {
                            cont = true;
                        }
                    }
                }
            }
        }
예제 #2
0
파일: IOStream.cs 프로젝트: Bhanditz/manos
        private void FinishCurrentWrite()
        {
            if (current_write_op == null)
            {
                return;
            }

            current_write_op.EndWrite(this);

            if (write_ops.Count > 0)
            {
                IWriteOperation op = write_ops.Dequeue();
                op.BeginWrite(this);
                current_write_op = op;
            }
            else
            {
                current_write_op = null;
                DisableWriting();
            }
        }
예제 #3
0
 public void HandleWrite(IIOStream stream)
 {
     this.stream = (ISocketStream)stream;
     if (currentPrefixBlock != null && !currentPrefixBlock.IsComplete)
     {
         currentPrefixBlock.HandleWrite(stream);
         if (currentPrefixBlock.IsComplete)
         {
             currentPrefixBlock.EndWrite(stream);
             currentPrefixBlock.Dispose();
             currentPrefixBlock = null;
         }
     }
     if (fd == -1)
     {
         OpenFile();
     }
     else if (Length == -1)
     {
         if (!Chunked)
         {
             stream.DisableWriting();
         }
         else
         {
             InitializeTransfer();
         }
     }
     else if (position != Length)
     {
         SendNextBlock();
     }
     else
     {
         OnComplete(0, 0);
     }
 }