2 EIBD eib bus access and management daemon
3 Copyright (C) 2005-2011 Martin Koegler <mkoegler@auto.tuwien.ac.at>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 TRACEPRINTF (t
, 8, this, "StopServer");
29 for (int i
= 0; i
< connections (); i
++)
30 connections
[i
]->StopDelete ();
31 while (connections () != 0)
36 TRACEPRINTF (t
, 8, this, "Server ended");
40 Server::deregister (ClientConnection
* con
)
42 for (unsigned i
= 0; i
< connections (); i
++)
43 if (connections
[i
] == con
)
45 connections
.deletepart (i
, 1);
51 Server::Server (Layer3
* layer3
, Trace
* tr
)
59 Server::Run (pth_sem_t
* stop1
)
61 pth_event_t stop
= pth_event (PTH_EVENT_SEM
, stop1
);
62 while (pth_event_status (stop
) != PTH_STATUS_OCCURRED
)
65 cfd
= pth_accept_ev (fd
, 0, 0, stop
);
68 TRACEPRINTF (t
, 8, this, "New Connection");
69 setupConnection (cfd
);
70 ClientConnection
*c
= new ClientConnection (this, l3
, t
, cfd
);
71 connections
.setpart (&c
, connections (), 1);
75 pth_event_free (stop
, PTH_FREE_THIS
);
79 Server::setupConnection (int cfd
)