Exemple #1
0
        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;
                        }
                    }
                }
            }
        }
Exemple #2
0
        protected virtual void HandleWrite()
        {
            if (current_write_op == null)
            {
                // Kinda shouldn't happen...
                DisableWriting();
                return;
            }

            current_write_op.HandleWrite(this);

            if (current_write_op.IsComplete)
            {
                FinishCurrentWrite();
            }
        }
Exemple #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);
     }
 }
Exemple #4
0
        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;
                    }
                }
            }
        }