extending by using procedurallanguage C : problems accessing shared memory
От | Feite Brekeveld |
---|---|
Тема | extending by using procedurallanguage C : problems accessing shared memory |
Дата | |
Msg-id | 3DFE1220.9020006@osiris-it.nl обсуждение исходный текст |
Ответы |
Re: extending by using procedurallanguage C : problems
|
Список | pgsql-general |
Hi, I'm having some trouble extending postgresql with some C-functions. Although I have done some tests with examples that work fine I have trouble in a function in which I wat to access data that is in shared memory. Functionalty is split into 2 functions because the ti_shmmav fuction is also used by other programs. Trouble is in the second function where I use the shmat call . Is there a way to do this ? When running : select shmmav(2785298, 1); // the large number is the segment id I get the following message: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The connection to the server was lost. Attempting reset: Failed. * There is data in the shared memory and I've tested it using a perlscript to perform the same kind of operation Some hints would be very helpful, thanks , Feite Brekeveld ----------------------code snippet -------------------------------------------- double *shmmav(int *shmid, int *period) { double *ret = palloc(sizeof(double)); *ret = ti_shmmav(shmid , period); return ret; } double ti_shmmav(int *shmid, int *period) { double ret; PREC *pprec; int i = 0; double total = 0.0; pprec = (PREC *)shmat( *shmid, NULL, SHM_RDONLY); if ( pprec == NULL) { fprintf(stderr, "Error attaching SHM: id %d\n", *shmid); } while (i < *period) { total += pprec[i].c; i++; } ret = total / (float)(*period); shmdt(pprec); return ret; } ------------------------------------------------------------------
В списке pgsql-general по дате отправления: