ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/init.C
(Generate patch)

Comparing deliantra/server/socket/init.C (file contents):
Revision 1.33 by pippijn, Sat Jan 6 14:42:31 2007 UTC vs.
Revision 1.34 by root, Sun Jan 7 02:39:15 2007 UTC

59: fd (fd), host (strdup (peername)), 59: fd (fd), host (strdup (peername)),
60 socket_ev (this, &client::socket_cb), 60 socket_ev (this, &client::socket_cb),
61 cmd_ev (this, &client::cmd_cb), 61 cmd_ev (this, &client::cmd_cb),
62 cc_inv (this), cc_other (this) 62 cc_inv (this), cc_other (this)
63{ 63{
64 refcnt_inc (); // the socket is an external reference
65
64 { 66 {
65 struct linger linger_opt; 67 struct linger linger_opt;
66 68
67 linger_opt.l_onoff = 0; 69 linger_opt.l_onoff = 0;
68 linger_opt.l_linger = 0; 70 linger_opt.l_linger = 0;
150 152
151 // initialisation done, kick it! 153 // initialisation done, kick it!
152 send_packet_printf ("version %d %d %s\n", VERSION_CS, VERSION_SC, VERSION_INFO); 154 send_packet_printf ("version %d %d %s\n", VERSION_CS, VERSION_SC, VERSION_INFO);
153 flush (); 155 flush ();
154 156
155 // clients are externally referenced by the socket 157 clients.insert (this);
156 refcnt_inc ();
157 clients.push_back (this);
158
159#if 0//TODO
160 socket_info.nconns++;
161 if (socket_info.nconns > cst_tot.max_conn) cst_tot.max_conn = socket_info.nconns;
162 if (socket_info.nconns > cst_lst.max_conn) cst_lst.max_conn = socket_info.nconns;
163#endif
164} 158}
165 159
166client::~client () 160client::~client ()
167{ 161{
168 sockvec::iterator i = find (clients.begin (), clients.end (), this);
169 if (i != clients.end ())
170 clients.erase (i); 162 clients.erase (this);
171 163
172 sfree<uint8> (faces_sent, nrofpixmaps); 164 sfree<uint8> (faces_sent, nrofpixmaps);
173 free (stats.range); 165 free (stats.range);
174 free (stats.title); 166 free (stats.title);
175 free (host); 167 free (host);
182 174
183 if (pl) 175 if (pl)
184 pl->disconnect (); 176 pl->disconnect ();
185 177
186 if (fd >= 0) 178 if (fd >= 0)
179 {
180 send_packet ("goodbye");
181 flush ();
182
187 close (fd); 183 close (fd);
184 }
188 185
189 state = ST_DEAD; 186 state = ST_DEAD;
190 187
191 socket_ev.suspend (); 188 socket_ev.suspend ();
192 cmd_ev.suspend (); 189 cmd_ev.suspend ();
193 190
194 // socket now longer references us 191 refcnt_dec (); // socket no longer open
195 refcnt_dec ();
196} 192}
197 193
198/** This sets up the socket and reads all the image information into memory. */ 194/** This sets up the socket and reads all the image information into memory. */
199void 195void
200init_ericserver (void) 196init_ericserver (void)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines