aboutsummaryrefslogtreecommitdiff
path: root/libssh/packet.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2006-12-12 16:32:34 +0000
committerAris Adamantiadis <aris@0xbadc0de.be>2006-12-12 16:32:34 +0000
commit4479b4aded35f52a49f20053ed81161037818cb6 (patch)
treee58259f557474b59270078e060cbe436d442cf55 /libssh/packet.c
parent77db3bba379688814c3a3f3a182cd87d91941861 (diff)
downloadlibssh-4479b4aded35f52a49f20053ed81161037818cb6.tar.gz
libssh-4479b4aded35f52a49f20053ed81161037818cb6.tar.xz
libssh-4479b4aded35f52a49f20053ed81161037818cb6.zip
norbert's patches + strange typo in packet_nonblocking_flush()
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@97 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/packet.c')
-rw-r--r--libssh/packet.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libssh/packet.c b/libssh/packet.c
index 900671dd..61034979 100644
--- a/libssh/packet.c
+++ b/libssh/packet.c
@@ -101,7 +101,8 @@ static int socket_read(SSH_SESSION *session,int len){
if(r<=0){
ssh_set_error(session,SSH_FATAL,
(r==0)?"Connection closed by remote host" : "Error reading socket");
- close(session->fd);
+ if(session->fd>=0)
+ close(session->fd);
session->fd=-1;
session->data_except=1;
return SSH_ERROR;
@@ -359,8 +360,13 @@ static int packet_nonblocking_flush(SSH_SESSION *session){
int except, can_write;
int w;
ssh_fd_poll(session,&can_write,&except); /* internally sets data_to_write */
+ if(session->fd<0){
+ session->alive=0;
+ ssh_set_error(session,SSH_FATAL,"Writing packet : error on socket (or connection closed): %s",strerror(errno));
+ return SSH_ERROR;
+ }
while(session->data_to_write && buffer_get_rest_len(session->out_socket_buffer)>0){
- if(session->fd<0){
+ if(session->fd>=0){
w=write(session->fd,buffer_get_rest(session->out_socket_buffer),
buffer_get_rest_len(session->out_socket_buffer));
session->data_to_write=0;