comparison common-session.c @ 751:685d05f1cc5c

Just put the version string on the queue, don't use atomicio
author Matt Johnston <matt@ucc.asn.au>
date Wed, 03 Apr 2013 19:23:53 +0800
parents 70811267715c
children 2f1c199b6e4b
comparison
equal deleted inserted replaced
750:a813e2752fdb 751:685d05f1cc5c
31 #include "dss.h" 31 #include "dss.h"
32 #include "ssh.h" 32 #include "ssh.h"
33 #include "random.h" 33 #include "random.h"
34 #include "kex.h" 34 #include "kex.h"
35 #include "channel.h" 35 #include "channel.h"
36 #include "atomicio.h"
37 #include "runopts.h" 36 #include "runopts.h"
38 37
39 static void checktimeouts(); 38 static void checktimeouts();
40 static long select_timeout(); 39 static long select_timeout();
41 static int ident_readln(int fd, char* buf, int count); 40 static int ident_readln(int fd, char* buf, int count);
47 * cleanest, but works OK */ 46 * cleanest, but works OK */
48 int sessinitdone = 0; /* GLOBAL */ 47 int sessinitdone = 0; /* GLOBAL */
49 48
50 /* this is set when we get SIGINT or SIGTERM, the handler is in main.c */ 49 /* this is set when we get SIGINT or SIGTERM, the handler is in main.c */
51 int exitflag = 0; /* GLOBAL */ 50 int exitflag = 0; /* GLOBAL */
52
53
54 51
55 /* called only at the start of a session, set up initial state */ 52 /* called only at the start of a session, set up initial state */
56 void common_session_init(int sock_in, int sock_out) { 53 void common_session_init(int sock_in, int sock_out) {
57 54
58 TRACE(("enter session_init")) 55 TRACE(("enter session_init"))
255 chancleanup(); 252 chancleanup();
256 253
257 TRACE(("leave session_cleanup")) 254 TRACE(("leave session_cleanup"))
258 } 255 }
259 256
260
261 void send_session_identification() { 257 void send_session_identification() {
262 /* write our version string, this blocks */ 258 buffer *writebuf = buf_new(strlen(LOCAL_IDENT "\r\n") + 1);
263 if (atomicio(write, ses.sock_out, LOCAL_IDENT "\r\n", 259 buf_putbytes(writebuf, LOCAL_IDENT "\r\n", strlen(LOCAL_IDENT "\r\n"));
264 strlen(LOCAL_IDENT "\r\n")) == DROPBEAR_FAILURE) { 260 buf_putbyte(writebuf, 0x0); // packet type
265 ses.remoteclosed(); 261 buf_setpos(writebuf, 0);
266 } 262 enqueue(&ses.writequeue, writebuf);
267 } 263 }
268 264
269 static void read_session_identification() { 265 static void read_session_identification() {
270 /* max length of 255 chars */ 266 /* max length of 255 chars */
271 char linebuf[256]; 267 char linebuf[256];