Update of /cvsroot/dnsmail/dnsmail/DnsMail
In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv30321/dnsmail/DnsMail
Modified Files:
Tag: DNSMAIL_02
DnsMail.cs
Log Message:
Some optimisation while sending data.
Index: DnsMail.cs
===================================================================
RCS file: /cvsroot/dnsmail/dnsmail/DnsMail/DnsMail.cs,v
retrieving revision 1.2.4.1
retrieving revision 1.2.4.2
diff -C2 -d -r1.2.4.1 -r1.2.4.2
*** DnsMail.cs 17 Jul 2006 12:51:51 -0000 1.2.4.1
--- DnsMail.cs 2 Aug 2006 17:06:14 -0000 1.2.4.2
***************
*** 778,825 ****
private void sendbuffereddata(StringBuilder header)
{
! byte[] buffer; int len;
! try
{
// :::::::::::::: Send Headers ::::::::::::
buffer = m_Enc.GetBytes( header.ToString() );
! header.Remove(0, header.Length); header = null;
int sent = SocketWrite(buffer, buffer.Length);
if (sent <= 0 || sent != buffer.Length)
throw new Exception("Headers couldn't be sent!");
! // ::::::::::::::::: Send Body :::::::::::::::::
! if (mi.Body != null && (len=mi.Body.Length) > 0)
{
! String body = mi.Body;
! char[] buffchar = new char[MaxBuffer];
! int totalsent = 0, remain, tosend;
! bool finalbuffer = false;
! remain = len;
! do
{
! if (remain > MaxBuffer)
! tosend = MaxBuffer;
! else
! {
! tosend = remain;
! finalbuffer = true;
! }
! body.CopyTo(totalsent, buffchar, 0, tosend);
! //qp encode
! buffer = MIME.QPEncode(
! m_Enc.GetBytes(buffchar, 0, tosend),
! finalbuffer ? SmtpEncode.All : SmtpEncode.Dot
! );
! // send
! sent = SocketWrite(buffer, buffer.Length);
! if((sent<=0)||(sent!=buffer.Length)) break;
! totalsent += tosend; remain -= tosend;
! OnSendProgress(totalsent, remain);
! buffer = null;
}
- while( totalsent < len && m_Client.Connected);
- Array.Clear(buffchar, 0, buffchar.Length);
- body = null; buffchar = null;
}
len = sent = 0;
}
--- 778,837 ----
private void sendbuffereddata(StringBuilder header)
{
! byte[] buffer;
! try
{
+ int len, tosend;
// :::::::::::::: Send Headers ::::::::::::
buffer = m_Enc.GetBytes( header.ToString() );
! header.Remove(0, header.Length);
! header = null;
int sent = SocketWrite(buffer, buffer.Length);
if (sent <= 0 || sent != buffer.Length)
throw new Exception("Headers couldn't be sent!");
! if (mi.Body == null || (len=mi.Body.Length) <= 0)
! goto Label_finish;
!
! int remain = len;
! int totalsent = 0;
! bool finalbuffer = false;
!
! String body = mi.Body;
! char[] buffchar = new char[MaxBuffer];
!
! Label_loop:
!
! if (remain > MaxBuffer)
! tosend = MaxBuffer;
! else
{
! tosend = remain;
! finalbuffer = true;
! }
!
! body.CopyTo(totalsent, buffchar, 0, tosend);
! //qp encode
! buffer = MIME.QPEncode(
! m_Enc.GetBytes(buffchar, 0, tosend),
! finalbuffer ? SmtpEncode.All : SmtpEncode.Dot
! );
! // send
! sent = SocketWrite(buffer, buffer.Length);
! if ((sent > 0) && sent == buffer.Length)
! {
! totalsent += tosend;
! remain -= tosend;
! OnSendProgress(totalsent, remain);
! buffer = null;
! if ((totalsent < len) && m_Client.Connected)
{
! goto Label_loop;
}
}
+
+ body = null;
+ buffchar = null;
+
+ Label_finish:
len = sent = 0;
}
***************
*** 828,833 ****
try
{
! if (m_Client != null && m_Client.Connected &&
! m_Client.Poll(TimeOut, SelectMode.SelectWrite))
SocketWrite(crlf_dot_crlf, crlf_dot_crlf.Length);
}
--- 840,844 ----
try
{
! if (m_Client != null && m_Client.Connected && m_Client.Poll(TimeOut, SelectMode.SelectWrite))
SocketWrite(crlf_dot_crlf, crlf_dot_crlf.Length);
}
***************
*** 836,840 ****
}
}
!
private byte[] recvBuffer;
private Commands SendAndReceive(String val)
--- 847,851 ----
}
}
!
private byte[] recvBuffer;
private Commands SendAndReceive(String val)
|