ok, I'll use process.nextTick instead.

On 2月1日, 下午7时50分, Ben Noordhuis <[email protected]> wrote:
> On Fri, Feb 1, 2013 at 9:42 AM, darcy <[email protected]> wrote:
> > Yes, I mean write+callback can be sync in some cases.
> > If the callback should be promised to be async, we can use
> > process.nextTick(cb.bind(this)) in Socket._write().
> > But I think in userland it's not important whether write callback is sync or
> > async. And in current implement callback is also sync if some error occurs.
>
> The callback should always be asynchronous (i.e. run on the next
> tick), or you introduce the risk of stack overflows.
>
> Consider this code:
>
>   var conn = net.connect(/* ... */, function() {
>     function write() { conn.write('PING', write) }
>     write();
>   });
>
> If the network connection is fast enough that the write always
> succeeds and the callback is synchronous, you'll overflow the call
> stack in seconds flat.

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to