* RPC xdr_free segmentation fault
@ 2014-11-10 0:37 Tomas By
0 siblings, 0 replies; only message in thread
From: Tomas By @ 2014-11-10 0:37 UTC (permalink / raw
To: guile-user
Hi all,
I'm trying to write a Guile/C RPC client (I know about guile-rpc but would
like to get this working also).
The dir.x and server code is the standard RPC example. I have only
modified the client (code below).
It works fine as far as the xdr_free at the bottom, which causes a
segmentation fault.
Any help appreciated.
/Tomas
---------- begin client.c ----------
#include <stdio.h>
#include "dir.h" /* generated by rpcgen */
#include <errno.h>
#include <libguile.h>
CLIENT* clnt;
SCM readdir_wrapper(SCM o) {
if (scm_is_string(o)) {
char* s;
readdir_res* result;
namelist nl;
scm_dynwind_begin(0);
s = scm_to_locale_string(o);
scm_dynwind_free(s);
result = readdir_1(s,clnt);
scm_dynwind_end();
if (result == (readdir_res*)NULL) {
clnt_perror(clnt,"localhost");
} else {
if (result->erna != 0) {
errno = result->erna;
perror(s);
} else {
for (nl = result->readdir_res_u.list; nl != NULL; nl = nl->next) {
printf("%s\n",nl->name);
}
printf("\n");
}
xdr_free((xdrproc_t)xdr_readdir_res,(char*)result);
}
} else {
scm_wrong_type_arg("read-dir",1,o);
}
}
static void inner_main(void* data,int argc,char** argv) {
scm_c_define_gsubr("read-dir",1,0,0,readdir_wrapper);
scm_shell(argc,argv);
}
int main(int argc,char* argv[]) {
clnt = clnt_create("localhost",DIRPROG,DIRVERS,"tcp");
if (clnt == (CLIENT*)NULL) {
clnt_pcreateerror("localhost");
exit(1);
}
scm_boot_guile(argc,argv,inner_main,NULL);
/*clnt_destroy(clnt);*/
return 0;
}
---------- end client.c ----------
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-11-10 0:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-10 0:37 RPC xdr_free segmentation fault Tomas By
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).