Commit a62879f73522a41855b893a8a390716961722a0d

Authored by Georg Hopp
1 parent 1e6a8550

compile with latest library versions, escpecialy the new socket code.

... ... @@ -32,6 +32,7 @@ TR_CLASS(ApplicationAdapterHttp) {
32 32 Application application;
33 33 Router router;
34 34 };
  35 +TR_INSTANCE_INIT(ApplicationAdapterHttp);
35 36
36 37 #endif // __APPLICATION_ADAPTER_HTTP_H__
37 38
... ...
... ... @@ -67,6 +67,7 @@ TR_CLASS(Application) {
67 67 const char * version;
68 68 const char * loc;
69 69 };
  70 +TR_INSTANCE_INIT(Application);
70 71
71 72 int applicationLogin(Application, Credential, Session);
72 73 void applicationLogout(Application, Session);
... ...
... ... @@ -49,6 +49,7 @@ TR_CLASS(Asset) {
49 49
50 50 size_t ref_count;
51 51 };
  52 +TR_INSTANCE_INIT(Asset);
52 53
53 54 Asset assetPoolGet(const char *, size_t);
54 55 size_t assetPoolRelease(Asset);
... ...
... ... @@ -58,6 +58,7 @@ typedef enum e_AuthModule {
58 58 TR_CLASS(Auth) {
59 59 void * auth[MAX_AUTH + 1];
60 60 };
  61 +TR_INSTANCE_INIT(Auth);
61 62
62 63 int authCreate(Auth, AuthModule, ...);
63 64
... ...
... ... @@ -48,6 +48,7 @@ TR_CLASS(Credential) {
48 48
49 49 } cred;
50 50 };
  51 +TR_INSTANCE_INIT(Credential);
51 52
52 53 #endif // __AUTH_CREDENTIAL_H__
53 54
... ...
... ... @@ -35,6 +35,7 @@ TR_CLASS(AuthLdap) {
35 35 int version;
36 36 size_t nbase_dn;
37 37 };
  38 +TR_INSTANCE_INIT(AuthLdap);
38 39
39 40 #endif // __AUTH_LDAP_H__
40 41
... ...
... ... @@ -38,6 +38,7 @@
38 38 TR_CLASS(AuthStorage) {
39 39 Storage store;
40 40 };
  41 +TR_INSTANCE_INIT(AuthStorage);
41 42
42 43 /**
43 44 * \todo In future this should use a more general purpose hash
... ...
... ... @@ -34,6 +34,7 @@ TR_CLASS(Config) {
34 34 char * cnf_file;
35 35 TR_Hash config;
36 36 };
  37 +TR_INSTANCE_INIT(Config);
37 38
38 39 ConfigValue configGet(Config, const char *, size_t);
39 40
... ...
... ... @@ -48,6 +48,7 @@ TR_CLASS(ConfigValue) {
48 48
49 49 unsigned long hash;
50 50 };
  51 +TR_INSTANCE_INIT(ConfigValue);
51 52
52 53 #endif // __CONFIG_VALUE_H__
53 54
... ...
... ... @@ -42,6 +42,7 @@ TR_CLASS(HttpCookie) {
42 42 size_t nkey;
43 43 size_t nvalue;
44 44 };
  45 +TR_INSTANCE_INIT(HttpCookie);
45 46
46 47 char * httpCookieToString(HttpCookie);
47 48 HttpCookie httpStringToCookie(const char *);
... ...
... ... @@ -40,6 +40,7 @@ TR_CLASS(HttpHeader) {
40 40 size_t cvalue; //!< count of values up to N_VALUE
41 41 size_t size; //!< full size of this header
42 42 };
  43 +TR_INSTANCE_INIT(HttpHeader);
43 44
44 45 size_t httpHeaderToString(HttpHeader, char *);
45 46
... ...
... ... @@ -39,6 +39,7 @@ TR_CLASS(HttpMessage) {
39 39 int nbody;
40 40 int dbody;
41 41 };
  42 +TR_INSTANCE_INIT(HttpMessage);
42 43
43 44 char httpMessageHasKeepAlive(HttpMessage);
44 45 size_t httpMessageHeaderSizeGet(HttpMessage);
... ...
... ... @@ -54,6 +54,7 @@ TR_CLASS(HttpParser) {
54 54
55 55 HttpMessageState state;
56 56 };
  57 +TR_INSTANCE_INIT(HttpParser);
57 58
58 59 ssize_t httpParserParse(void *, TR_Stream);
59 60 void httpParserRequestVars(HttpParser);
... ...
... ... @@ -56,6 +56,7 @@ TR_CLASS(HttpRequest) {
56 56 TR_Hash post;
57 57 TR_Hash cookies;
58 58 };
  59 +TR_INSTANCE_INIT(HttpRequest);
59 60
60 61 HttpMethod httpRequestGetMethodId(HttpRequest);
61 62
... ...
... ... @@ -40,6 +40,7 @@ TR_CLASS(HttpResponse) {
40 40 unsigned int status;
41 41 char * reason;
42 42 };
  43 +TR_INSTANCE_INIT(HttpResponse);
43 44
44 45 HttpResponse httpResponse304(
45 46 const char *, size_t,
... ...
... ... @@ -40,7 +40,7 @@
40 40
41 41 TR_CLASS(HttpWorker) {
42 42 char * id;
43   - TR_Sock socket;
  43 + TR_Socket socket;
44 44
45 45 TR_Cbuf pbuf;
46 46 TR_Hash asset_pool;
... ... @@ -55,6 +55,7 @@ TR_CLASS(HttpWorker) {
55 55 HttpParser parser;
56 56 HttpWriter writer;
57 57 };
  58 +TR_INSTANCE_INIT(HttpWorker);
58 59
59 60 #endif // __HTTP_WORKER_H__
60 61
... ...
... ... @@ -89,6 +89,7 @@ TR_CLASS(HttpWriter) {
89 89
90 90 HttpWriterState state;
91 91 };
  92 +TR_INSTANCE_INIT(HttpWriter);
92 93
93 94 ssize_t httpWriterWrite(void *, TR_Stream);
94 95
... ...
... ... @@ -52,6 +52,7 @@ TR_CLASS(Permission) {
52 52 char * resource;
53 53 ResourceAction action;
54 54 };
  55 +TR_INSTANCE_INIT(Permission);
55 56
56 57 #endif // __PERMISSION_H__
57 58
... ...
... ... @@ -33,6 +33,7 @@ TR_CLASS(RbacObject) {
33 33 char * name;
34 34 size_t nname;
35 35 };
  36 +TR_INSTANCE_INIT(RbacObject);
36 37
37 38 #endif // __RBAC_OBJECT_H__
38 39
... ...
... ... @@ -32,6 +32,7 @@ TR_CLASS(RbacOperation) {
32 32 char * name;
33 33 size_t nname;
34 34 };
  35 +TR_INSTANCE_INIT(RbacOperation);
35 36
36 37
37 38 #endif // __RBAC_OPERATION_H__
... ...
... ... @@ -41,6 +41,7 @@ TR_CLASS(RbacUser) {
41 41 char * name;
42 42 size_t nname;
43 43 };
  44 +TR_INSTANCE_INIT(RbacUser);
44 45
45 46 // void userSerialize(User, void **, size_t *);
46 47 // void userDeserialize(User, void *, size_t);
... ...
... ... @@ -95,7 +95,9 @@ TR_CLASS(Role) {
95 95
96 96 User * users;
97 97 Hash users_idx;
  98 + // end og ROLE definition.
98 99 };
  100 +TR_INSTANCE_INIT(Role);
99 101
100 102 #endif // __ROLE_H__
101 103
... ...
... ... @@ -51,6 +51,7 @@ TR_CLASS(Router) {
51 51 char * prefix;
52 52 size_t nprefix;
53 53 };
  54 +TR_INSTANCE_INIT(Router);
54 55
55 56 HttpResponse routerRoute(Router, HttpRequest, Session);
56 57
... ...
... ... @@ -35,15 +35,15 @@
35 35 #include "trio.h"
36 36
37 37 struct conns {
38   - TR_Sock sock;
  38 + TR_Socket sock;
39 39 TR_Stream stream;
40 40 void * worker;
41 41 };
42 42
43 43 TR_CLASS(Server) {
44 44 TR_Logger logger;
45   - TR_Sock sock;
46   - TR_Sock sockSSL;
  45 + TR_Socket sock;
  46 + TR_Socket sockSSL;
47 47 SSL_CTX * ctx;
48 48 void * worker;
49 49
... ... @@ -53,6 +53,7 @@ TR_CLASS(Server) {
53 53
54 54 struct conns * conns;
55 55 };
  56 +TR_INSTANCE_INIT(Server);
56 57
57 58 void serverRun(Server this);
58 59
... ...
... ... @@ -70,6 +70,7 @@ TR_CLASS(Session) {
70 70 time_t livetime;
71 71 User user;
72 72 };
  73 +TR_INSTANCE_INIT(Session);
73 74
74 75 #endif // __SESSION_H__
75 76
... ...
... ... @@ -41,6 +41,7 @@ TR_CLASS(Storage) {
41 41 GDBM_FILE gdbm;
42 42 char * db_name;
43 43 };
  44 +TR_INSTANCE_INIT(Storage);
44 45
45 46 StoragePutResult storagePut(Storage, char *, size_t, char *, size_t);
46 47 StoragePutResult storageUpdate(Storage, char *, size_t, char *, size_t);
... ...
... ... @@ -53,6 +53,7 @@ TR_CLASS(User) {
53 53 size_t * nfirstname;
54 54 size_t * nsurname;
55 55 };
  56 +TR_INSTANCE_INIT(User);
56 57
57 58 #endif // __USER_H__
58 59
... ...
... ... @@ -34,15 +34,16 @@
34 34 int
35 35 serverHandleAccept(Server this, unsigned int i)
36 36 {
37   - char remoteAddr[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
38   - TR_Sock acc = NULL;
39   - TR_Stream st;
  37 + TR_Socket acc = NULL;
  38 + TR_Stream st;
40 39
41 40 if (this->nfds >= this->max_fds) {
42 41 return -1;
43 42 }
44 43
45   - acc = TR_socketAccept((0 == i)? this->sock : this->sockSSL, &remoteAddr);
  44 + acc = (TR_Socket)TR_socketAccept((0 == i)
  45 + ? (TR_TcpSocket)this->sock
  46 + : (TR_TcpSocket)this->sockSSL);
46 47
47 48 if (NULL != acc && -1 != acc->handle) {
48 49 TR_socketNonblock(acc);
... ...
... ... @@ -65,11 +65,13 @@ serverCtor(void * _this, va_list * params)
65 65 this->fds = TR_calloc(sizeof(struct pollfd), this->max_fds);
66 66 this->conns = TR_calloc(sizeof(struct conns), this->max_fds);
67 67
68   - this->sock = TR_new(TR_Sock, this->logger, port);
  68 + this->sock = TR_new(TR_TcpSocket, this->logger, "0.0.0.0", port, 0);
69 69 TR_socketNonblock(this->sock);
  70 + TR_socketBind((TR_Socket)this->sock);
70 71
71   - this->sockSSL = TR_new(TR_Sock, this->logger, port+1);
  72 + this->sockSSL = TR_new(TR_TcpSocket, this->logger, "0.0.0.0", port+1, 0);
72 73 TR_socketNonblock(this->sockSSL);
  74 + TR_socketBind((TR_Socket)this->sockSSL);
73 75
74 76 SSL_library_init();
75 77 OpenSSL_add_all_algorithms();
... ... @@ -88,9 +90,6 @@ serverCtor(void * _this, va_list * params)
88 90 CONFIGDIR "/taskrambler.pem",
89 91 SSL_FILETYPE_PEM);
90 92
91   - TR_socketListen(this->sock, backlog);
92   - TR_socketListen(this->sockSSL, backlog);
93   -
94 93 (this->fds)[0].fd = this->sock->handle;
95 94 (this->fds)[0].events = POLLIN;
96 95 (this->fds)[1].fd = this->sockSSL->handle;
... ...
Please register or login to post a comment