Re: Pthread lock on g_once_init_enter (&g_define_type_id__volatile) [RESOLVED]



Hello again,

I discovered what happened. The function generated get_type was calling itself. So double initialization, and the second one on the same thread was stopped because the thread lock.

The error was here

G_DEFINE_TYPE(ThriftSSLSocket, thrift_ssl_socket, THRIFT_TYPE_SSL_SOCKET)

It was instanciating a subclass of itself. Should be like this:

G_DEFINE_TYPE(ThriftSSLSocket, thrift_ssl_socket, THRIFT_TYPE_SOCKET)

Thank you for the help.



El 06/10/15 a las 10:36, Gonzalo Aguilar Delgado escribió:
Hello,

Maybe someone here can help me. I defined a subclass of another existing class.

Basicly:

typedef struct _ThriftSSLSocket ThriftSSLSocket;

struct _ThriftSSLSocket
{
  ThriftSocket parent;

  /* private */
};
typedef struct _ThriftSSLSocketClass ThriftSSLSocketClass;

struct _ThriftSSLSocketClass
{
    ThriftSocketClass parent;
};
// More code here


And in the C file I'm defining this new type:

G_DEFINE_TYPE(ThriftSSLSocket, thrift_ssl_socket, THRIFT_TYPE_SSL_SOCKET)

// More code here




Looks good sofar. But when I do:

  object = g_object_new (THRIFT_TYPE_SSL_SOCKET, NULL);


It stalls waiting for the macro expansion here:


  static volatile gsize g_define_type_id__volatile = 0;
    if (g_once_init_enter (&g_define_type_id__volatile)) {   <<<<<----------- Because a thread lock.
        GType g_define_type_id =



The question is why? Maybe the base class is not derivable?


Best regards,


_______________________________________________
gtk-list mailing list
gtk-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]