From: "Tomas By" <tomas@basun.net>
To: guile-user@gnu.org
Subject: RPC xdr_free segmentation fault
Date: Mon, 10 Nov 2014 01:37:00 +0100 [thread overview]
Message-ID: <4f4e17196a1586a8a5109c9ff8fe8883.squirrel@webmail.xs4all.nl> (raw)
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 ----------
reply other threads:[~2014-11-10 0:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4f4e17196a1586a8a5109c9ff8fe8883.squirrel@webmail.xs4all.nl \
--to=tomas@basun.net \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).