ume05rw / SharpCifs.Std

SharpCifs.Std is a port from SharpCifs to .NET Standard. Original SharpCifs: https://github.com/zinkpad/SharpCifs
GNU Lesser General Public License v2.1
86 stars 34 forks source link

异常未捕捉到导致死循环 #36

Open YouXinxing opened 4 years ago

YouXinxing commented 4 years ago

当samba服务断开或者异常的时候,请求连接时, var remote = (IPEndPoint)this.Socket?.RemoteEndPoint; RemoteEndPoint 强制类型的转码类是 EndPoint 出现异常,导致异常类SmbException没有捕捉到,ConnectionState不能重置为0,导致程序在下一次连接时,在 while (ConnectionState != 0) { if (ConnectionState == 2 || ConnectionState == 3) { // connected or disconnecting return; } try { Runtime.Wait(Session.transport,2000); } catch (Exception ie) { throw new SmbException(ie.Message, ie); } } 这边一直死循环,阻塞进程,另外Runtime.Wait(Session.transport,2000);中,等待超时应该设置一个超时间,这样程序更灵活一点。 望修复,感谢开源。