joswa / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

Callback user pointer #184

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The older versions used to have an user pointer sent to the callback function, 
which made easier the life of programmers (this was not necessary to keep a 
global pointer to the current app instance).

I've noticed this is gone in this new version. Do you have any intention to put 
this user pointer again on the callback?

Regards!

Carlos.

Original issue reported on code.google.com by carlos...@gmail.com on 4 Oct 2010 at 7:50

GoogleCodeExporter commented 9 years ago
No, I don't think user pointer is useful anymore.
It was useful before because callbacks could have been added after mg_start().
Now,
  1. All configuration should be done before mg_start()
  2. There is only one callback, not multiple ones

Original comment by valenok on 4 Oct 2010 at 10:05

GoogleCodeExporter commented 9 years ago
Thanks for the prompt response!

As I am from the old school I don't like global variables for N reasons I'll 
not bug you. I'll let my Xmas wish with you, please, add it again! :-)

Original comment by carlos...@gmail.com on 5 Oct 2010 at 6:51

GoogleCodeExporter commented 9 years ago
I made use of the callback user data, and have added it back rather than 
refactor to use globals.

Original comment by nbjo...@gmail.com on 8 Oct 2010 at 7:28

GoogleCodeExporter commented 9 years ago
Yes, that's what I did also. I just wanted this to be in the basis, so when 
there is an update we don't have to keep doing such changes...

Thanks for the reply!

Carlos.

Original comment by carlos...@gmail.com on 8 Oct 2010 at 7:58

GoogleCodeExporter commented 9 years ago
I completely agree!

Original comment by nbjo...@gmail.com on 8 Oct 2010 at 9:57

GoogleCodeExporter commented 9 years ago
D'oh. Just saw this *after* creating a fork that added a user_pointer.

For the curious, have a look at http://code.google.com/r/ericscouten-mongoose/.

Original comment by eric.sco...@gmail.com on 19 Oct 2010 at 4:02

GoogleCodeExporter commented 9 years ago
Eric, are the link you've provided seems to address different issue.

Original comment by valenok on 19 Oct 2010 at 6:35

GoogleCodeExporter commented 9 years ago
Hmm. It would appear that's a bug in Google Code. I pushed two independent head 
revisions to that clone but only the most recent one appears. That is indeed 
for a different issue.

I've created a second clone that contains only this patch: 
http://code.google.com/r/ericscouten-mongoose2/

Original comment by eric.sco...@gmail.com on 19 Oct 2010 at 7:12

GoogleCodeExporter commented 9 years ago
What about:
1. add "void *user_data" to the mg_start(), i.e.
      struct mg_context *mg_start(mg_callback_t callback, void *user_data, const char **options);
2. add "void *user_data" to the struct mg_request_info

Original comment by valenok on 19 Oct 2010 at 7:29

GoogleCodeExporter commented 9 years ago
That is fine with me also. I was trying to maintain compatibility with the 
existing mg_start, but this may make more sense.

Shall I roll a new patch?

Original comment by eric.sco...@gmail.com on 19 Oct 2010 at 7:47

GoogleCodeExporter commented 9 years ago
That would be awesome! I was quite frustrated of having a global variable just 
because of mongoose.
IMHO the best place to put the user pointer is really on mg_start() and struct 
mg_request_info.

If backward compatibility is a problem, just create a "mg_start_ex()" instead, 
and macro mg_start(a,b) -> mg_start_ex(a,b,NULL).

Original comment by rodrigo...@gmail.com on 19 Oct 2010 at 8:02

GoogleCodeExporter commented 9 years ago
Revised patch posted at http://code.google.com/r/ericscouten-mongoose2/

Original comment by eric.sco...@gmail.com on 19 Oct 2010 at 9:30

GoogleCodeExporter commented 9 years ago
Looks good to me. I'll integrate that.
If the API changes, I'll bump up the major version number, for all other 
releases only minor version number will be increased. So with this change in, 
it'll be mongoose 3.0.

Original comment by valenok on 19 Oct 2010 at 10:03

GoogleCodeExporter commented 9 years ago
Submitted 
http://code.google.com/p/mongoose/source/detail?r=9061029592953203dfa09eabcba6f1
85996f80a9

Original comment by valenok on 26 Oct 2010 at 10:39