[Vortex] socket program demonstrates vortex problem

Philip Kovacs kovacsp3 at comcast.net
Thu Jun 15 05:07:47 CEST 2006


Please compile the attached demo program with:

gcc `pkg-config --cflags --libs vortex` -o socket socket.c

The vortex server I am using is the demo server in the vortex documentation
that runs PLAIN_PROFILE:

http://www.aspl.es/fact/files/af-arch/vortex/html/profile_example.html

The program attempts to open a unix domain socket after a vortex channel is
opened.  The socket code is completely independent of vortex and does not
use or interact with the vortex connection or channel.

The issue I am concerned about is why the vortex reader interacts with
the socket code and issues an intermittent critical warning.  (You may
have to run the socket program several times to see the error). 
There is an i/o interaction problem here.

Note that the actual programs involved are considerably more complex,
but I wanted to simplify the problem as much as I could for demonstration
purposes.

Phil

-------------- next part --------------
/* socket.c 
 * by Philip Kovacs 
 * a small demo program illustrating intermittent Vortex issue 
 * */

#include <vortex.h>
#include <glib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>

#define PLAIN_PROFILE "http://fact.aspl.es/profiles/plain_profile"

gint
connect_to_session(gint session)
{
    gint fd;
    uid_t stored_uid, euid;
    struct sockaddr_un saddr;

    if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) {
        saddr.sun_family = AF_UNIX;
        stored_uid = getuid();
        euid = geteuid();
        setuid(euid);
        g_snprintf(saddr.sun_path, 108, "%s/%s_%s.%d", g_get_tmp_dir(),
                   "nothing", g_get_user_name(), session);
        setreuid(stored_uid, euid);
        if (connect(fd, (struct sockaddr *) &saddr, sizeof(saddr)) != -1)
            return fd;
    }
    close(fd);
    return -1;
}

gint main()
{
    VortexConnection *conn;
    VortexChannel    *chan;

    /* try it with this set to get the vortex error message:
       vortex_reader: proc xxxxx: tries have been reached on reader, exiting.. */ 
    g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);

    vortex_init();
    conn = vortex_connection_new ("localhost","44000",0,0);
    chan = vortex_channel_new (conn,0,PLAIN_PROFILE,0,0,0,0,0,0);

    g_message ("socket connect status: %d", connect_to_session(0));

    vortex_channel_close (chan,NULL);
    vortex_connection_close (conn);
    vortex_exit ();
    return 0;
}


More information about the Vortex mailing list