Removed the protocol registration updates in the splash screen for Python

dissectors, because it does not work as expected and causes an assert.

Added generic splash updates for python register and handoff instead.

This should fix bug 5431.

svn path=/trunk/; revision=39221
This commit is contained in:
Stig Bjørlykke 2011-10-02 16:19:55 +00:00
parent 44f914a0f1
commit 64c2355b67
5 changed files with 25 additions and 36 deletions

View File

@ -393,7 +393,9 @@ proto_init(void (register_all_protocols_func)(register_cb cb, gpointer client_da
register_all_protocols_func(cb, client_data);
#ifdef HAVE_PYTHON
/* Now scan for python protocols */
register_all_py_protocols_func(cb, client_data);
if(cb)
(*cb)(RA_PYTHON_REGISTER, NULL, client_data);
register_all_py_protocols_func();
#endif
#ifdef HAVE_PLUGINS
@ -413,7 +415,9 @@ proto_init(void (register_all_protocols_func)(register_cb cb, gpointer client_da
#ifdef HAVE_PYTHON
/* Now do the same with python dissectors */
register_all_py_handoffs_func(cb, client_data);
if(cb)
(*cb)(RA_PYTHON_HANDOFF, NULL, client_data);
register_all_py_handoffs_func();
#endif
#ifdef HAVE_PLUGINS

View File

@ -88,17 +88,8 @@ char * py_dissector_name(PyObject * py_dissector)
/**
* Register the dissector
*/
void py_dissector_register(PyObject * py_dissector, char * py_name, register_cb cb, gpointer client_data)
void py_dissector_register(PyObject * py_dissector)
{
/* const char * py_name; */
/* Get the name of the dissector */
/* py_name = py_dissector_name(py_dissector); */
/* Register dissector in register_cb */
if (cb)
(*cb)(RA_REGISTER, py_name, client_data);
/**
* Register protocol, fields, subtrees
*
@ -125,7 +116,7 @@ static const char *get_py_register_file(void)
/**
* Finds out all the python dissectors and register them
*/
void register_all_py_protocols_func(register_cb cb _U_, gpointer client_data _U_)
void register_all_py_protocols_func(void)
{
FILE * py_reg;
PyObject * global_dict, * main_module, * register_fn;
@ -177,7 +168,7 @@ void register_all_py_protocols_func(register_cb cb _U_, gpointer client_data _U_
for (index = 0; (py_dissector = PySequence_GetItem(py_dissectors, index)); index++)
{
name = py_dissector_name(py_dissector);
py_dissector_register(py_dissector, name, cb, client_data);
py_dissector_register(py_dissector);
g_hash_table_insert(g_py_dissectors, (gpointer*)name, py_dissector);
}
}
@ -236,21 +227,9 @@ dissector_t py_generic_dissector(void)
return &py_dissect;
}
struct SRegisterHandoffsForeach {
register_cb cb;
gpointer client_data;
};
static void register_all_py_handoffs_foreach(gpointer key _U_, gpointer value, gpointer user_data)
static void register_all_py_handoffs_foreach(gpointer key _U_, gpointer value, gpointer user_data _U_)
{
PyObject * py_dissector = (PyObject *)value;
struct SRegisterHandoffsForeach *rhf = (struct SRegisterHandoffsForeach*)user_data;
/* STA TODO : it's the short_desc field ... not really the filter field! */
char * handoff_name = g_strdup_printf("handoff_%s", py_dissector_name(py_dissector));
if (rhf->cb)
(*(rhf->cb))(RA_HANDOFF, handoff_name, rhf->client_data);
PyObject_CallMethod(py_dissector, "register_handoff", NULL);
}
@ -259,14 +238,9 @@ static void register_all_py_handoffs_foreach(gpointer key _U_, gpointer value, g
* Finalize the registration of the python protocol dissectors
*/
void
register_all_py_handoffs_func(register_cb cb, gpointer client_data)
register_all_py_handoffs_func(void)
{
struct SRegisterHandoffsForeach rhf;
rhf.cb = cb;
rhf.client_data = client_data;
g_hash_table_foreach(g_py_dissectors, register_all_py_handoffs_foreach, &rhf);
g_hash_table_foreach(g_py_dissectors, register_all_py_handoffs_foreach, NULL);
}
#endif /* HAVE_PYTHON */

View File

@ -29,8 +29,8 @@ extern "C" {
#endif /* __cplusplus */
#ifdef HAVE_PYTHON
void register_all_py_protocols_func(register_cb cb, gpointer client_data);
void register_all_py_handoffs_func(register_cb cb, gpointer client_data);
void register_all_py_protocols_func(void);
void register_all_py_handoffs_func(void);
#endif
#ifdef __cplusplus

View File

@ -210,12 +210,18 @@ splash_update(register_action_e action, const char *message, gpointer client_dat
case RA_PLUGIN_REGISTER:
action_msg = "Registering plugins ...";
break;
case RA_PYTHON_REGISTER:
action_msg = "Registering Python dissectors ...";
break;
case RA_HANDOFF:
action_msg = "Handing off dissector ...";
break;
case RA_PLUGIN_HANDOFF:
action_msg = "Handing off plugins ...";
break;
case RA_PYTHON_HANDOFF:
action_msg = "Handing off Python dissectors ...";
break;
case RA_LUA_PLUGINS:
action_msg = "Loading Lua plugins ...";
break;
@ -240,6 +246,9 @@ splash_update(register_action_e action, const char *message, gpointer client_dat
preferences and configuration */
#ifdef HAVE_LUA_5_1
ul_count++; /* additional one for lua plugins */
#endif
#ifdef HAVE_PYTHON
ul_count += 2; /* additional 2 for python register and handoff */
#endif
}

View File

@ -33,8 +33,10 @@ typedef enum {
RA_LISTENERS, /* Tap listeners */
RA_REGISTER, /* register */
RA_PLUGIN_REGISTER, /* plugin register */
RA_PYTHON_REGISTER, /* python register */
RA_HANDOFF, /* handoff */
RA_PLUGIN_HANDOFF, /* plugin handoff */
RA_PYTHON_HANDOFF, /* python handoff */
RA_LUA_PLUGINS, /* lua plugin register */
RA_PREFERENCES, /* module preferences */
RA_CONFIGURATION /* configuration files */