断管的错误 [英] Broken Pipe error

查看:224
本文介绍了断管的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的FTP执行一个打开的数据套接字写入()发送文件了。但是,写一些数据后,它被挂了一段时间;之后,它与管道中断错误时返回。在这个任何帮助将大大AP preciated。我的过程从一个BUFF读取数据包,并在插座上写道。我注意到这个问题,更高的带宽。如果我增加了待处理的数据包数量,那么问题来了,我使用的FreeBSD。

我用两个线程一曰分组,并在一个缓冲区写入...第二个线程从缓冲区中读取这些数据包,并写入到插座上。

感谢您的帮助
亚历山大


解决方案

SIGPIPE 被送到当检测到内核的过程中尝试将数据写入到一个破裂的管道。这可能发生,例如,如果接收方套接字已被关闭,而你写,或者如果插座不慎从另一个线程关闭等方面有很多针对可能的原因。大多数应用程序往往会忽略这个信号并处理错误立足于返回code,因为没有什么合理的,你可以在 SIGPIPE 信号处理的处理函数中执行。基本上,为了忽略它,并期待在可能的返回$列表 SIGPIPE 处理程序设置为SIG_IGN C $ CS从系统调用,并相应地处理它们。

I am using write() on a opened data socket in FTP implementation to send the file out. But after writing some data it is hanging for some time; and after that it is returning with Broken pipe error. any help in this will greatly appreciated. My process reads packets from one buff and writes in to the socket. I noticed this problem with increased bandwidth. If i increased number of packets to be processed then the problem is coming. i am using FreeBSD.

I am using two threads one reads packets and writes in to a buffer ... second thread reads these packets from buffer and writes in to socket.

Thanks For your help Alexander

解决方案

SIGPIPE is sent to your process by the kernel when attempt to write data to a broken pipe is detected. This might happen, for example, if receiving side has closed the socket while you writing, or if socket is accidentally closed from another thread, etc. There are a lot of possible reasons for that. Most applications tend to ignore this signal and handle errors basing on "write" return code because there is nothing reasonable you can do in SIGPIPE signal processing handler. Basically, set SIGPIPE handler to SIG_IGN in order to ignore it and look at a list of possible return codes from "write" system call and handle them accordingly.

这篇关于断管的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆