Fixes #11 Segmentation fault.
This commit is contained in:
parent
01dbe4e0ce
commit
745124ebd6
4 changed files with 39 additions and 19 deletions
25
lib/Curl.js
25
lib/Curl.js
|
@ -1,6 +1,6 @@
|
|||
// Generated by ToffeeScript 1.4.0
|
||||
(function() {
|
||||
var Curl, m, p;
|
||||
var Curl, curls, id, m, p;
|
||||
|
||||
try {
|
||||
Curl = require(__dirname + '/../build/Release/node-curl').Curl;
|
||||
|
@ -8,6 +8,10 @@
|
|||
Curl = require(__dirname + '/../build/default/node-curl').Curl;
|
||||
}
|
||||
|
||||
curls = {};
|
||||
|
||||
id = 0;
|
||||
|
||||
Curl.prototype.setopt_user_ = function(option_id, value) {
|
||||
return this.options[option_id] = value;
|
||||
};
|
||||
|
@ -54,15 +58,26 @@
|
|||
};
|
||||
|
||||
Curl.prototype.on = function(event, callback) {
|
||||
var _this = this;
|
||||
switch (event) {
|
||||
case 'data':
|
||||
this.on_write = callback;
|
||||
break;
|
||||
case 'error':
|
||||
this.on_error = callback;
|
||||
this.on_error = function() {
|
||||
var rt;
|
||||
rt = callback();
|
||||
curls[_this.id] = null;
|
||||
return rt;
|
||||
};
|
||||
break;
|
||||
case 'end':
|
||||
this.on_end = callback;
|
||||
this.on_end = function() {
|
||||
var rt;
|
||||
rt = callback();
|
||||
curls[_this.id] = null;
|
||||
return rt;
|
||||
};
|
||||
break;
|
||||
default:
|
||||
throw new Error("invalid event type " + event);
|
||||
|
@ -71,6 +86,8 @@
|
|||
};
|
||||
|
||||
Curl.prototype.perform = function() {
|
||||
this.id = ++id;
|
||||
curls[this.id] = this;
|
||||
this.perform_();
|
||||
Curl.process();
|
||||
return this;
|
||||
|
@ -95,7 +112,7 @@
|
|||
return process.nextTick(once);
|
||||
} else {
|
||||
m = 0;
|
||||
w = (8192 - n) * 80 / 8192;
|
||||
w = (8192 - n) * 80 / 8192 >> 0;
|
||||
if (w < 0) {
|
||||
w = 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue