[MonetDB-users] connecting streams to Mapi.
Hi. I'm investigating how to connect custom streams to a Mapi structure. I've been reading, for instance the start_mal_server() function of monetdb5-server-5.16.2/src/tools/embeddedclient.c.in. I now sort of understand how the stream library works (though not fully), and I'm trying to understand how the streams are effectively used by the client of the Mapi struct. I've therefore looking at the start_mal_server() function, and here's a piece of code whose semantics I do not understand:
in = ((stream **) arg)[0]; out = ((stream **) arg)[1]; free(arg); snprintf(buf, sizeof(buf), "in := \"" PTRFMT "\":streams;\n" "out := \"" PTRFMT "\":streams;\n" "mapi.malclient(in, out);\n", PTRFMTCAST in, PTRFMTCAST out); callString(mal_clients, buf, 0);
I'm specifically interested in the 'in' stream since it is the one I would like to write to. Could someone enlighten me here? All the best, -- Guillaume Yziquel http://yziquel.homelinux.org/
On 2010-02-04 13:09, Guillaume Yziquel wrote:
Hi.
I'm investigating how to connect custom streams to a Mapi structure. I've been reading, for instance the start_mal_server() function of monetdb5-server-5.16.2/src/tools/embeddedclient.c.in.
I now sort of understand how the stream library works (though not fully), and I'm trying to understand how the streams are effectively used by the client of the Mapi struct.
I've therefore looking at the start_mal_server() function, and here's a piece of code whose semantics I do not understand:
in = ((stream **) arg)[0]; out = ((stream **) arg)[1]; free(arg); snprintf(buf, sizeof(buf), "in := \"" PTRFMT "\":streams;\n" "out := \"" PTRFMT "\":streams;\n" "mapi.malclient(in, out);\n", PTRFMTCAST in, PTRFMTCAST out); callString(mal_clients, buf, 0);
I'm specifically interested in the 'in' stream since it is the one I would like to write to.
Could someone enlighten me here?
All the best,
It's a bit of a hack. The problem is, we have a C pointer to a stream and we want to give that to the MAL layer. So what happens is, a MAL command is constructed which looks something like in := "0x123456":streams; The string value "0x123456" is cast to a MAL streams type, and in doing so, the string is interpreted as a number and the numeric value is then used. -- Sjoerd Mullender
Sjoerd Mullender a écrit :
in = ((stream **) arg)[0]; out = ((stream **) arg)[1]; free(arg); snprintf(buf, sizeof(buf), "in := \"" PTRFMT "\":streams;\n" "out := \"" PTRFMT "\":streams;\n" "mapi.malclient(in, out);\n", PTRFMTCAST in, PTRFMTCAST out); callString(mal_clients, buf, 0);
I'm specifically interested in the 'in' stream since it is the one I would like to write to.
Could someone enlighten me here?
All the best,
It's a bit of a hack. The problem is, we have a C pointer to a stream and we want to give that to the MAL layer. So what happens is, a MAL command is constructed which looks something like in := "0x123456":streams; The string value "0x123456" is cast to a MAL streams type, and in doing so, the string is interpreted as a number and the numeric value is then used.
OK. You probably do that for the reason that the libraries compiled out of mal_mapi.mx are dynamically loaded, and beause of that, you cannot just use the symbols they provide in your code. Am I wrong? But then, concerning the administrator: he can communicate through stdin and stdout as I've read somewhere. Where can I find the hardcoded equivalent of the above call to mapi.malclient, when it comes to streams for the admin? All the best, -- Guillaume Yziquel http://yziquel.homelinux.org/
Guillaume Yziquel a écrit :
It's a bit of a hack. The problem is, we have a C pointer to a stream and we want to give that to the MAL layer. So what happens is, a MAL command is constructed which looks something like in := "0x123456":streams; The string value "0x123456" is cast to a MAL streams type, and in doing so, the string is interpreted as a number and the numeric value is then used.
OK. So I understand now that this scheme allows to have two threads communicate with a pipe. The code is written in such a way that nothing is blocking, here. OK. But then, I wonder how things are done from the server side. I've been looking at the streams library, and I do not understand how the server, or rather the client thread, waits for input. I expect that it is not done through polling, but rather some kind of select statement. Therefore two questions: -1- How is the streams library supposed to be used when it comes to using select? -2- Where is the code which keeps the client thread waiting in a non-busy mode? All the best, -- Guillaume Yziquel http://yziquel.homelinux.org/
Guillaume Yziquel a écrit :
-2- Where is the code which keeps the client thread waiting in a non-busy mode?
Specifically, the following comment in mal_client.mx is rather misleading:
The routines defined below provide management of the client administration. Routines dealing with serviceing requests are located in mal_startup.
There's no file whose name contains mal_startup, and no such function name. All the best, -- Guillaume Yziquel http://yziquel.homelinux.org/
participants (2)
-
Guillaume Yziquel
-
Sjoerd Mullender