Index: files/patch-lib-erl_interface-src-connect-ei_connect.c.diff
===================================================================
--- files/patch-lib-erl_interface-src-connect-ei_connect.c.diff	(revision 0)
+++ files/patch-lib-erl_interface-src-connect-ei_connect.c.diff	(revision 0)
@@ -0,0 +1,137 @@
+--- lib/erl_interface/src/connect/ei_connect.c	2006-05-03 10:03:39.000000000 +0200
++++ lib/erl_interface/src/connect/ei_connect.c	2009-01-19 14:52:25.000000000 +0100
+@@ -100,6 +100,11 @@
+ 
+ #define COOKIE_FILE "/.erlang.cookie"
+ #define EI_MAX_HOME_PATH 1024
++#define DEFAULT_FLAGS \
++    (DFLAG_EXTENDED_REFERENCES \
++		| DFLAG_EXTENDED_PIDS_PORTS \
++		| DFLAG_FUN_TAGS \
++		| DFLAG_NEW_FUN_TAGS)
+ 
+ /* FIXME why not macro? */
+ static char *null_cookie = "";
+@@ -114,7 +119,7 @@
+ static int send_status(int fd, char *status, unsigned ms);
+ static int recv_status(int fd, unsigned ms);
+ static int send_challenge(int fd, char *nodename, 
+-			  unsigned challenge, unsigned version, unsigned ms);
++			  unsigned challenge, unsigned version, unsigned ms, unsigned flags);
+ static int recv_challenge(int fd, unsigned *challenge, 
+ 			  unsigned *version,
+ 			  unsigned *flags, ErlConnect *namebuf, unsigned ms);
+@@ -129,7 +134,7 @@
+ 			      unsigned our_challenge,
+ 			      char cookie[], unsigned ms);
+ static int send_name(int fd, char *nodename, 
+-		     unsigned version, unsigned ms); 
++		     unsigned version, unsigned ms, unsigned flags); 
+ 
+ /* Common for both handshake types */
+ static int recv_name(int fd, 
+@@ -566,6 +571,11 @@
+ */
+ int ei_connect_tmo(ei_cnode* ec, char *nodename, unsigned ms)
+ {
++    return ei_connect_tmo_flags(ec, nodename, ms, DEFAULT_FLAGS);
++}
++
++int ei_connect_tmo_flags(ei_cnode* ec, char *nodename, unsigned ms, unsigned our_flags)
++{
+     char *hostname, alivename[BUFSIZ];
+     struct hostent *hp;
+ #if !defined (__WIN32__) 
+@@ -636,7 +646,7 @@
+ 	}
+     }
+ #endif /* win32 */
+-    return ei_xconnect_tmo(ec, (Erl_IpAddr) *hp->h_addr_list, alivename, ms);
++    return ei_xconnect_tmo_flags(ec, (Erl_IpAddr) *hp->h_addr_list, alivename, ms, our_flags);
+ } /* ei_connect */
+ 
+ int ei_connect(ei_cnode* ec, char *nodename)
+@@ -653,6 +663,11 @@
+ */
+ int ei_xconnect_tmo(ei_cnode* ec, Erl_IpAddr adr, char *alivename, unsigned ms)
+ {
++    return ei_xconnect_tmo_flags(ec, adr, alivename, ms, DEFAULT_FLAGS);
++}
++
++int ei_xconnect_tmo_flags(ei_cnode* ec, Erl_IpAddr adr, char *alivename, unsigned ms, unsigned our_flags)
++{
+     struct in_addr *ip_addr=(struct in_addr *) adr;
+     int rport = 0; /*uint16 rport = 0;*/
+     int sockd;
+@@ -690,7 +705,7 @@
+ 	unsigned our_challenge, her_challenge;
+ 	unsigned char our_digest[16];
+ 	
+-	if (send_name(sockd, ec->thisnodename, (unsigned) dist, ms))
++	if (send_name(sockd, ec->thisnodename, (unsigned) dist, ms, our_flags))
+ 	    goto error;
+ 	if (recv_status(sockd, ms))
+ 	    goto error;
+@@ -749,6 +764,11 @@
+ 
+ int ei_accept_tmo(ei_cnode* ec, int lfd, ErlConnect *conp, unsigned ms)
+ {
++    return ei_accept_tmo_flags(ec, lfd, conp, ms, DEFAULT_FLAGS);
++}
++
++int ei_accept_tmo_flags(ei_cnode* ec, int lfd, ErlConnect *conp, unsigned ms, unsigned our_flags)
++{
+     int fd;
+     struct sockaddr_in cli_addr;
+     int cli_addr_len=sizeof(struct sockaddr_in);
+@@ -786,7 +806,7 @@
+ 	    goto error;
+ 	our_challenge = gen_challenge();
+ 	if (send_challenge(fd, ec->thisnodename, 
+-	    our_challenge, her_version, ms))
++	    our_challenge, her_version, ms, our_flags))
+ 	    goto error;
+ 	if (recv_challenge_reply(fd, our_challenge, 
+ 	    ec->ei_connect_cookie, 
+@@ -1288,7 +1308,8 @@
+ 				  int f_chall,
+ 				  unsigned challenge,
+ 				  unsigned version,
+-				  unsigned ms) 
++				  unsigned ms,
++				  unsigned our_flags) 
+ {
+     char *buf;
+     unsigned char *s;
+@@ -1308,10 +1329,7 @@
+     put16be(s,siz - 2);
+     put8(s, 'n');
+     put16be(s, version);
+-    put32be(s, (DFLAG_EXTENDED_REFERENCES
+-		| DFLAG_EXTENDED_PIDS_PORTS
+-		| DFLAG_FUN_TAGS
+-		| DFLAG_NEW_FUN_TAGS));
++    put32be(s, our_flags);
+     if (f_chall)
+ 	put32be(s, challenge);
+     memcpy(s, nodename, strlen(nodename));
+@@ -1563,15 +1581,15 @@
+     return -1;
+ }
+ 
+-static int send_name(int fd, char *nodename, unsigned version, unsigned ms) 
++static int send_name(int fd, char *nodename, unsigned version, unsigned ms, unsigned flags) 
+ {
+-    return send_name_or_challenge(fd, nodename, 0, 0, version, ms);
++    return send_name_or_challenge(fd, nodename, 0, 0, version, ms, flags);
+ }
+ 
+ static int send_challenge(int fd, char *nodename, 
+-			  unsigned challenge, unsigned version, unsigned ms)
++			  unsigned challenge, unsigned version, unsigned ms, unsigned flags)
+ {
+-    return send_name_or_challenge(fd, nodename, 1, challenge, version, ms);
++    return send_name_or_challenge(fd, nodename, 1, challenge, version, ms, flags);
+ }
+ 
+ static int recv_name(int fd, 
Index: files/patch-lib-erl_interface-include-ei.h.diff
===================================================================
--- files/patch-lib-erl_interface-include-ei.h.diff	(revision 0)
+++ files/patch-lib-erl_interface-include-ei.h.diff	(revision 0)
@@ -0,0 +1,21 @@
+--- lib/erl_interface/include/ei.h	2008-04-07 15:58:08.000000000 +0200
++++ lib/erl_interface/include/ei.h	2009-01-19 14:54:50.000000000 +0100
+@@ -302,8 +302,10 @@
+ 
+ int ei_connect(ei_cnode* ec, char *nodename);
+ int ei_connect_tmo(ei_cnode* ec, char *nodename, unsigned ms);
++int ei_connect_tmo_flags(ei_cnode* ec, char *nodename, unsigned ms, unsigned flags);
+ int ei_xconnect(ei_cnode* ec, Erl_IpAddr adr, char *alivename);
+ int ei_xconnect_tmo(ei_cnode* ec, Erl_IpAddr adr, char *alivename, unsigned ms);
++int ei_xconnect_tmo_flags(ei_cnode* ec, Erl_IpAddr adr, char *alivename, unsigned ms, unsigned flags);
+ 
+ int ei_receive(int fd, unsigned char *bufp, int bufsize);
+ int ei_receive_tmo(int fd, unsigned char *bufp, int bufsize, unsigned ms);
+@@ -328,6 +330,7 @@
+ int ei_publish_tmo(ei_cnode* ec, int port, unsigned ms);
+ int ei_accept(ei_cnode* ec, int lfd, ErlConnect *conp);
+ int ei_accept_tmo(ei_cnode* ec, int lfd, ErlConnect *conp, unsigned ms);
++int ei_accept_tmo_flags(ei_cnode* ec, int lfd, ErlConnect *conp, unsigned ms, unsigned flags);
+ int ei_unpublish(ei_cnode* ec);
+ int ei_unpublish_tmo(const char *alive, unsigned ms);
+ 
Index: Portfile
===================================================================
--- Portfile	(revision 50671)
+++ Portfile	(working copy)
@@ -1,9 +1,9 @@
-# $Id: Portfile 44939 2009-01-04 23:22:47Z bfulgham@macports.org $
+# $Id$
 
 PortSystem 1.0
 name		erlang
 version		R13B
-revision        2
+revision    3
 categories	lang erlang
 maintainers	bfulgham@macports.org
 platforms	darwin
@@ -26,11 +26,14 @@
                 Ericsson ATM switch. 
 
 homepage        http://www.erlang.org/
-master_sites    http://www.erlang.org/download/
+master_sites    http://www.erlang.org/download/ \
+                http://www.erlang.org/download/patches/:patches
 
+
 distfiles       otp_src_${version}${extract.suffix}                    \
                 otp_doc_man_${version}${extract.suffix}                \
-                otp_doc_html_${version}${extract.suffix}
+                otp_doc_html_${version}${extract.suffix}               \
+                eunit-2.1.1.tar.gz:patches
 
 checksums       otp_src_${version}.tar.gz \
                     md5     6d8c256468a198458b9f08ba6aa1a384 \
@@ -43,14 +46,22 @@
                 otp_doc_html_${version}.tar.gz \
                     md5     a14b1111550ce2bce65090de5cf3b0ff \
                     sha1    d479dc6f865ae0cd59a9085de20698fae9d71b67 \
-                    rmd160  632b54c5b4a2261d61377c171a9ca7e71176bd69
+                    rmd160  632b54c5b4a2261d61377c171a9ca7e71176bd69 \
+                eunit-2.1.1.tar.gz \
+                    md5     b29d3aa9a03b0be0c55ed729e41931a9 \
+                    sha1    339aca80925e560f5e6724d900a9a29cc72810b4 \
+                    rmd160  a483fb2dab4cb85558d33fa9a6747729d4730321
 
-extract.only    otp_src_${version}${extract.suffix}
+extract.only    otp_src_${version}${extract.suffix} eunit-2.1.1.tar.gz
+post-extract {
+    system "cd ${workpath}/eunit-2.1.1/ && tar cf - . | (cd ${workpath}/otp_src_${version}/lib/eunit ; tar xf -)"
+}
 
 pre-patch       { file rename ${workpath}/otp_src_${version} ${workpath}/${name}-${version} }
 
 # http://www.erlang.org/pipermail/erlang-bugs/2008-October/001023.html
 # http://www.erlang.org/pipermail/erlang-bugs/2008-October/001024.html
+# http://www.erlang.org/pipermail/erlang-bugs/2009-January/001171.html
 patchfiles	patch-toolbar.erl \
                 patch-erts_emulator_Makefile.in \
                 patch-lib_ssl_c_src_esock_openssl.c \
@@ -58,6 +69,8 @@
                 patch-lib_ssl_c_src_Makefile.in \
                 patch-decode_big.c.diff \
                 patch-decode_fun.c.diff \
+                patch-lib-erl_interface-src-connect-ei_connect.c.diff \
+                patch-lib-erl_interface-include-ei.h.diff \
                 patch-erts_configure.diff
 
 configure.args  --prefix=${destroot}${prefix}	\
@@ -78,8 +91,6 @@
 	configure.args-delete   --enable-hipe
 }
 
-
-
 depends_build   port:gawk \
                 port:wxWidgets
 depends_run     port:tk
