摘要: beanstalk把监听socket加入了epoll,当客户端有连接时,在主循环sockmain中通过处理epoll事件完成对连接的处理。1. 客户端连接处理代码通过前面对主循环的分析可以看出,监听socket的回调处理函数为srvaccept(见如下函数)。通过分析h_accept可以看出,客户端连接的处理包括三个步骤:a.建立连接socket,并将连接设置为非阻塞;b.创建连接管理对象,c.将和客户端的连接加入epoll连接处理#监听服务回调函数,用作接受连接voidsrvaccept(Server *s, int ev){ h_accept(s->sock.fd, ev, s);} 阅读全文
posted @ 2013-02-17 17:23 blockcipher 阅读(370) 评论(0) 推荐(0)
摘要: 以后的分析都是基于beanstalk版本1.6版本的源码。1. 服务实例Serverbeanstalk中将一个监听实例抽象成为一个Server, 服务实例是监听指定地址(ip:port)的运行实例。结构如下:serverstruct Server { char *port; //端口 char *addr; //地址 char *user; //用户 Wal wal; //binlog文件 Socket sock; //监听socket连接 Heap conns; //连接堆};2.epoll抽象beanstalk对epoll相关的函数... 阅读全文
posted @ 2013-02-17 16:36 blockcipher 阅读(396) 评论(0) 推荐(0)
摘要: <rem_hr>Object Oriented Programming Oversold!OOP criticism and OOP problems The emperor has no clothes! Reality Check 101 Snake OOilUpdated: 8/27/2006OOPMythsDebunked:Myth: OOP is a proven general-purpose techniqueMyth: OOP models the real world betterMyth: OOP makes programming more visualMyt 阅读全文
posted @ 2013-02-17 15:20 blockcipher 阅读(340) 评论(0) 推荐(0)
摘要: "If you look back at where object orientation came from with Smalltalk-80 with message passing, and look at the current state of inheritance and things like that, have we gone down the wrong path?" This is the opening question of aQCon London 2010 interviewwith Joe Armstrong, the original 阅读全文
posted @ 2013-02-17 14:56 blockcipher 阅读(270) 评论(0) 推荐(0)
摘要: If anyone knows the joys and sorrows of managing software development projects, it would be Linus Torvalds, creator of the world's most popular open-source software program: the Linux operating system. Formore than 20 years, Torvalds has been directing thousands of developersto improve the open 阅读全文
posted @ 2013-02-17 14:45 blockcipher 阅读(223) 评论(0) 推荐(0)
摘要: When I get asked "What's a good first programming language to teach my [son / daughter / other-person-with-no-programming-experience]?" my answer has been the same for the last 5+ years: Python. That may be unexpected, coming from someone who often talks about non-mainstream languages, 阅读全文
posted @ 2013-02-17 14:37 blockcipher 阅读(211) 评论(0) 推荐(0)
摘要: 在过去的N年中,我遇到了很多使用囧然不同风格的开发者,下面是我所知道的一些,你还知道其它的吗?散弹枪编程这种编程风格是一种开发者使用非常随意的方式对待代码。“嗯,这个方法调用出错了……那么我会试着把传出的参数从 false 变成 true!”,当然依然出错,于是我们的程序员会这样:“好吧,那我就注释掉整个方法吧”,或是其它更为随意的处理方式,直到最后让这个调用成功。或是被旁边的某个程序员指出一个正确的方法。如果我们把一个正规的程序员和一个撞大运的程序员放在一起做结地,那么,那个正规的程序可以马上变得发疯起来,并且,可以把正规的程序员的智商降到最低。两个撞大运的程序员不应该在一起做结对编程,这是 阅读全文
posted @ 2013-02-17 14:27 blockcipher 阅读(151) 评论(0) 推荐(0)