@@ -169,20 +169,20 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
169
169
iotask : iotask. clone ( )
170
170
} ;
171
171
let socket_data_ptr = ptr:: addr_of ( & ( * socket_data) ) ;
172
- log ( debug, fmt ! ( "tcp_connect result_ch %?" , conn_data. result_ch) ) ;
172
+ debug ! ( "tcp_connect result_ch %?" , conn_data. result_ch) ;
173
173
// get an unsafe representation of our stream_handle_ptr that
174
174
// we can send into the interact cb to be handled in libuv..
175
- log ( debug, fmt ! ( "stream_handle_ptr outside interact %?" ,
176
- stream_handle_ptr) ) ;
175
+ debug ! ( "stream_handle_ptr outside interact %?" ,
176
+ stream_handle_ptr) ;
177
177
do iotask:: interact ( iotask) |move input_ip, loop_ptr| {
178
178
unsafe {
179
- log ( debug, ~ "in interact cb for tcp client connect..");
180
- log( debug, fmt !(" stream_handle_ptr in interact %?",
181
- stream_handle_ptr) ) ;
179
+ debug ! ( "in interact cb for tcp client connect.." ) ;
180
+ debug ! ( "stream_handle_ptr in interact %?" ,
181
+ stream_handle_ptr) ;
182
182
match uv:: ll:: tcp_init ( loop_ptr, stream_handle_ptr) {
183
183
0i32 => {
184
- log ( debug, ~ "tcp_init successful") ;
185
- log ( debug, ~ "dealing w/ ipv4 connection..");
184
+ debug ! ( "tcp_init successful" ) ;
185
+ debug ! ( "dealing w/ ipv4 connection.." ) ;
186
186
let connect_req_ptr =
187
187
ptr:: addr_of ( & ( ( * socket_data_ptr) . connect_req ) ) ;
188
188
let addr_str = ip:: format_addr ( & input_ip) ;
@@ -195,7 +195,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
195
195
// type that actually is closer to
196
196
// what the libuv API expects (ip str
197
197
// + port num)
198
- log ( debug, fmt ! ( "addr: %?" , addr) ) ;
198
+ debug ! ( "addr: %?" , addr) ;
199
199
let in_addr = uv:: ll:: ip4_addr ( addr_str,
200
200
port as int ) ;
201
201
uv:: ll:: tcp_connect (
@@ -205,7 +205,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
205
205
tcp_connect_on_connect_cb)
206
206
}
207
207
ip:: Ipv6 ( ref addr) => {
208
- log ( debug, fmt ! ( "addr: %?" , addr) ) ;
208
+ debug ! ( "addr: %?" , addr) ;
209
209
let in_addr = uv:: ll:: ip6_addr ( addr_str,
210
210
port as int ) ;
211
211
uv:: ll:: tcp_connect6 (
@@ -217,7 +217,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
217
217
} ;
218
218
match connect_result {
219
219
0i32 => {
220
- log ( debug, ~ "tcp_connect successful") ;
220
+ debug ! ( "tcp_connect successful" ) ;
221
221
// reusable data that we'll have for the
222
222
// duration..
223
223
uv:: ll:: set_data_for_uv_handle (
@@ -228,8 +228,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
228
228
// outcome..
229
229
uv:: ll:: set_data_for_req ( connect_req_ptr,
230
230
conn_data_ptr) ;
231
- log ( debug,
232
- ~"leaving tcp_connect interact cb...");
231
+ debug ! ( "leaving tcp_connect interact cb..." ) ;
233
232
// let tcp_connect_on_connect_cb send on
234
233
// the result_ch, now..
235
234
}
@@ -260,12 +259,12 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
260
259
}
261
260
match oldcomm:: recv ( result_po) {
262
261
ConnSuccess => {
263
- log( debug, ~ " tcp:: connect - received success on result_po") ;
262
+ debug ! ( "tcp::connect - received success on result_po" ) ;
264
263
result:: Ok ( TcpSocket ( socket_data) )
265
264
}
266
265
ConnFailure ( ref err_data) => {
267
266
oldcomm:: recv ( closed_signal_po) ;
268
- log ( debug, ~ "tcp:: connect - received failure on result_po") ;
267
+ debug ! ( "tcp::connect - received failure on result_po" ) ;
269
268
// still have to free the malloc'd stream handle..
270
269
rustrt:: rust_uv_current_kernel_free ( stream_handle_ptr
271
270
as * libc:: c_void ) ;
@@ -379,8 +378,8 @@ pub fn read_stop(sock: &TcpSocket,
379
378
read_port : oldcomm:: Port < result:: Result < ~[ u8 ] , TcpErrData > > ) ->
380
379
result:: Result < ( ) , TcpErrData > {
381
380
unsafe {
382
- log ( debug,
383
- fmt ! ( "taking the read_port out of commission %?" , read_port) ) ;
381
+ debug ! (
382
+ "taking the read_port out of commission %?" , read_port) ;
384
383
let socket_data = ptr:: addr_of ( & ( * sock. socket_data ) ) ;
385
384
read_stop_common_impl ( socket_data)
386
385
}
@@ -548,7 +547,7 @@ pub fn accept(new_conn: TcpNewConnection)
548
547
// the rules here because this always has to be
549
548
// called within the context of a listen() new_connect_cb
550
549
// callback (or it will likely fail and drown your cat)
551
- log ( debug, ~ "in interact cb for tcp:: accept") ;
550
+ debug ! ( "in interact cb for tcp::accept" ) ;
552
551
let loop_ptr = uv:: ll:: get_loop_for_uv_handle (
553
552
server_handle_ptr) ;
554
553
match uv:: ll:: tcp_init ( loop_ptr, client_stream_handle_ptr) {
@@ -908,7 +907,7 @@ impl TcpSocketBuf: io::Reader {
908
907
self . end_of_stream
909
908
}
910
909
fn seek ( & self , dist : int , seek : io:: SeekStyle ) {
911
- log ( debug, fmt ! ( "tcp_socket_buf seek stub %? %?" , dist, seek) ) ;
910
+ debug ! ( "tcp_socket_buf seek stub %? %?" , dist, seek) ;
912
911
// noop
913
912
}
914
913
fn tell ( & self ) -> uint {
@@ -935,7 +934,7 @@ impl TcpSocketBuf: io::Writer {
935
934
}
936
935
}
937
936
fn seek ( & self , dist : int , seek : io:: SeekStyle ) {
938
- log ( debug, fmt ! ( "tcp_socket_buf seek stub %? %?" , dist, seek) ) ;
937
+ debug ! ( "tcp_socket_buf seek stub %? %?" , dist, seek) ;
939
938
// noop
940
939
}
941
940
fn tell ( & self ) -> uint {
@@ -1524,7 +1523,7 @@ pub mod test {
1524
1523
} ;
1525
1524
oldcomm:: recv ( cont_po) ;
1526
1525
// client
1527
- log ( debug, ~ "server started, firing up client..");
1526
+ debug ! ( "server started, firing up client.." ) ;
1528
1527
let actual_resp_result = do oldcomm:: listen |client_ch| {
1529
1528
run_tcp_test_client (
1530
1529
server_ip,
@@ -1536,10 +1535,10 @@ pub mod test {
1536
1535
assert actual_resp_result. is_ok ( ) ;
1537
1536
let actual_resp = actual_resp_result. get ( ) ;
1538
1537
let actual_req = oldcomm:: recv ( server_result_po) ;
1539
- log( debug, fmt !(" REQ : expected: ' %s' actual: ' %s' ",
1540
- expected_req, actual_req) ) ;
1541
- log ( debug, fmt ! ( "RESP: expected: '%s' actual: '%s'" ,
1542
- expected_resp, actual_resp) ) ;
1538
+ debug ! ( "REQ: expected: '%s' actual: '%s'" ,
1539
+ expected_req, actual_req) ;
1540
+ debug ! ( "RESP: expected: '%s' actual: '%s'" ,
1541
+ expected_resp, actual_resp) ;
1543
1542
assert str:: contains ( actual_req, expected_req) ;
1544
1543
assert str:: contains ( actual_resp, expected_resp) ;
1545
1544
}
@@ -1570,7 +1569,7 @@ pub mod test {
1570
1569
} ;
1571
1570
oldcomm:: recv ( cont_po) ;
1572
1571
// client
1573
- log ( debug, ~ "server started, firing up client..");
1572
+ debug ! ( "server started, firing up client.." ) ;
1574
1573
do oldcomm:: listen |client_ch| {
1575
1574
let server_ip_addr = ip:: v4:: parse_addr ( server_ip) ;
1576
1575
let iotask = uv:: global_loop:: get ( ) ;
@@ -1600,7 +1599,7 @@ pub mod test {
1600
1599
let server_port = 8889 u;
1601
1600
let expected_req = ~"ping";
1602
1601
// client
1603
- log ( debug, ~ "firing up client..");
1602
+ debug ! ( "firing up client.." ) ;
1604
1603
let actual_resp_result = do oldcomm:: listen |client_ch| {
1605
1604
run_tcp_test_client (
1606
1605
server_ip,
@@ -1647,7 +1646,7 @@ pub mod test {
1647
1646
server_port,
1648
1647
hl_loop) ;
1649
1648
// client.. just doing this so that the first server tears down
1650
- log ( debug, ~ "server started, firing up client..");
1649
+ debug ! ( "server started, firing up client.." ) ;
1651
1650
do oldcomm:: listen |client_ch| {
1652
1651
run_tcp_test_client (
1653
1652
server_ip,
@@ -1766,7 +1765,7 @@ pub mod test {
1766
1765
} ;
1767
1766
oldcomm:: recv ( cont_po) ;
1768
1767
// client
1769
- log ( debug, ~ "server started, firing up client..");
1768
+ debug ! ( "server started, firing up client.." ) ;
1770
1769
let server_addr = ip:: v4:: parse_addr ( server_ip) ;
1771
1770
let conn_result = connect ( move server_addr, server_port, hl_loop) ;
1772
1771
if result:: is_err ( & conn_result) {
@@ -1777,23 +1776,23 @@ pub mod test {
1777
1776
1778
1777
let buf_reader = sock_buf as Reader ;
1779
1778
let actual_response = str:: from_bytes ( buf_reader. read_whole_stream ( ) ) ;
1780
- log( debug, fmt !(" Actual response: %s", actual_response) ) ;
1779
+ debug ! ( "Actual response: %s" , actual_response) ;
1781
1780
assert expected_resp == actual_response;
1782
1781
}
1783
1782
1784
1783
fn buf_write < W : io:: Writer > ( w : & W , val : & str ) {
1785
- log ( debug, fmt ! ( "BUF_WRITE: val len %?" , str :: len( val) ) ) ;
1784
+ debug ! ( "BUF_WRITE: val len %?" , str :: len( val) ) ;
1786
1785
do str:: byte_slice ( val) |b_slice| {
1787
- log ( debug, fmt ! ( "BUF_WRITE: b_slice len %?" ,
1788
- vec:: len( b_slice) ) ) ;
1786
+ debug ! ( "BUF_WRITE: b_slice len %?" ,
1787
+ vec:: len( b_slice) ) ;
1789
1788
w. write ( b_slice)
1790
1789
}
1791
1790
}
1792
1791
1793
1792
fn buf_read < R : io:: Reader > ( r : & R , len : uint ) -> ~str {
1794
1793
let new_bytes = ( * r) . read_bytes ( len) ;
1795
- log ( debug, fmt ! ( "in buf_read.. new_bytes len: %?" ,
1796
- vec:: len( new_bytes) ) ) ;
1794
+ debug ! ( "in buf_read.. new_bytes len: %?" ,
1795
+ vec:: len( new_bytes) ) ;
1797
1796
str:: from_bytes ( new_bytes)
1798
1797
}
1799
1798
@@ -1806,65 +1805,61 @@ pub mod test {
1806
1805
iotask,
1807
1806
// on_establish_cb -- called when listener is set up
1808
1807
|kill_ch| {
1809
- log ( debug, fmt ! ( "establish_cb %?" ,
1810
- kill_ch) ) ;
1808
+ debug ! ( "establish_cb %?" , kill_ch) ;
1811
1809
oldcomm:: send ( cont_ch, ( ) ) ;
1812
1810
} ,
1813
1811
// risky to run this on the loop, but some users
1814
1812
// will want the POWER
1815
1813
|new_conn, kill_ch| {
1816
- log ( debug, ~ "SERVER : new connection!");
1814
+ debug ! ( "SERVER: new connection!" ) ;
1817
1815
do oldcomm:: listen |cont_ch| {
1818
1816
do task:: spawn_sched ( task:: ManualThreads ( 1 u) ) {
1819
- log( debug, ~ " SERVER : starting worker for new req") ;
1817
+ debug ! ( "SERVER: starting worker for new req" ) ;
1820
1818
1821
1819
let accept_result = accept ( new_conn) ;
1822
- log ( debug, ~ "SERVER : after accept( ) ") ;
1820
+ debug ! ( "SERVER: after accept()" ) ;
1823
1821
if result:: is_err ( & accept_result) {
1824
- log ( debug, ~ "SERVER : error accept connection") ;
1822
+ debug ! ( "SERVER: error accept connection" ) ;
1825
1823
let err_data = result:: get_err ( & accept_result) ;
1826
1824
oldcomm:: send ( kill_ch, Some ( err_data) ) ;
1827
- log ( debug,
1828
- ~"SERVER /WORKER : send on err cont ch") ;
1825
+ debug ! ( "SERVER/WORKER: send on err cont ch" ) ;
1829
1826
cont_ch. send ( ( ) ) ;
1830
1827
}
1831
1828
else {
1832
- log ( debug,
1833
- ~"SERVER /WORKER : send on cont ch") ;
1829
+ debug ! ( "SERVER/WORKER: send on cont ch" ) ;
1834
1830
cont_ch. send ( ( ) ) ;
1835
1831
let sock = result:: unwrap ( move accept_result) ;
1836
1832
let peer_addr = sock. get_peer_addr ( ) ;
1837
- log ( debug, ~"SERVER : successfully accepted"+
1838
- fmt ! ( " connection from %s:%u" ,
1833
+ debug ! ( "SERVER: successfully accepted connection from %s:%u" ,
1839
1834
ip:: format_addr( & peer_addr) ,
1840
- ip:: get_port( & peer_addr) ) ) ;
1835
+ ip:: get_port( & peer_addr) ) ;
1841
1836
let received_req_bytes = read ( & sock, 0 u) ;
1842
1837
match move received_req_bytes {
1843
1838
result:: Ok ( move data) => {
1844
- log ( debug, ~ "SERVER : got REQ str:: from_bytes..");
1845
- log( debug, fmt !(" SERVER : REQ data len: %?",
1846
- vec:: len ( data) ) ) ;
1839
+ debug ! ( "SERVER: got REQ str::from_bytes.." ) ;
1840
+ debug ! ( "SERVER: REQ data len: %?" ,
1841
+ vec:: len( data) ) ;
1847
1842
server_ch. send (
1848
1843
str:: from_bytes ( data) ) ;
1849
- log ( debug, ~ "SERVER : before write") ;
1844
+ debug ! ( "SERVER: before write" ) ;
1850
1845
tcp_write_single ( & sock, str:: to_bytes ( resp) ) ;
1851
- log ( debug, ~ "SERVER : after write.. die") ;
1846
+ debug ! ( "SERVER: after write.. die" ) ;
1852
1847
oldcomm:: send ( kill_ch, None ) ;
1853
1848
}
1854
1849
result:: Err ( move err_data) => {
1855
- log ( debug, fmt ! ( "SERVER: error recvd: %s %s" ,
1856
- err_data. err_name, err_data. err_msg) ) ;
1850
+ debug ! ( "SERVER: error recvd: %s %s" ,
1851
+ err_data. err_name, err_data. err_msg) ;
1857
1852
oldcomm:: send ( kill_ch, Some ( err_data) ) ;
1858
1853
server_ch. send ( ~"") ;
1859
1854
}
1860
1855
}
1861
- log ( debug, ~ "SERVER : worker spinning down") ;
1856
+ debug ! ( "SERVER: worker spinning down" ) ;
1862
1857
}
1863
1858
}
1864
- log ( debug, ~ "SERVER : waiting to recv on cont_ch") ;
1859
+ debug ! ( "SERVER: waiting to recv on cont_ch" ) ;
1865
1860
cont_ch. recv ( )
1866
1861
} ;
1867
- log ( debug, ~ "SERVER : recv' d on cont_ch..leaving listen cb") ;
1862
+ debug ! ( "SERVER: recv'd on cont_ch..leaving listen cb" ) ;
1868
1863
} ) ;
1869
1864
// err check on listen_result
1870
1865
if result:: is_err ( & listen_result) {
@@ -1882,7 +1877,7 @@ pub mod test {
1882
1877
}
1883
1878
}
1884
1879
let ret_val = server_ch. recv ( ) ;
1885
- log ( debug, fmt ! ( "SERVER: exited and got return val: '%s'" , ret_val) ) ;
1880
+ debug ! ( "SERVER: exited and got return val: '%s'" , ret_val) ;
1886
1881
ret_val
1887
1882
}
1888
1883
@@ -1893,8 +1888,7 @@ pub mod test {
1893
1888
iotask,
1894
1889
// on_establish_cb -- called when listener is set up
1895
1890
|kill_ch| {
1896
- log ( debug, fmt ! ( "establish_cb %?" ,
1897
- kill_ch) ) ;
1891
+ debug ! ( "establish_cb %?" , kill_ch) ;
1898
1892
} ,
1899
1893
|new_conn, kill_ch| {
1900
1894
fail fmt ! ( "SERVER: shouldn't be called.. %? %?" ,
@@ -1915,11 +1909,11 @@ pub mod test {
1915
1909
TcpConnectErrData > {
1916
1910
let server_ip_addr = ip:: v4:: parse_addr ( server_ip) ;
1917
1911
1918
- log ( debug, ~ "CLIENT : starting..");
1912
+ debug ! ( "CLIENT: starting.." ) ;
1919
1913
let connect_result = connect ( move server_ip_addr, server_port,
1920
1914
iotask) ;
1921
1915
if result:: is_err ( & connect_result) {
1922
- log( debug, ~ " CLIENT : failed to connect") ;
1916
+ debug ! ( "CLIENT: failed to connect" ) ;
1923
1917
let err_data = result:: get_err ( & connect_result) ;
1924
1918
Err ( err_data)
1925
1919
}
@@ -1929,14 +1923,13 @@ pub mod test {
1929
1923
tcp_write_single ( & sock, resp_bytes) ;
1930
1924
let read_result = sock. read ( 0 u) ;
1931
1925
if read_result. is_err ( ) {
1932
- log ( debug, ~ "CLIENT : failure to read") ;
1926
+ debug ! ( "CLIENT: failure to read" ) ;
1933
1927
Ok ( ~"")
1934
1928
}
1935
1929
else {
1936
1930
client_ch. send ( str:: from_bytes ( read_result. get ( ) ) ) ;
1937
1931
let ret_val = client_ch. recv ( ) ;
1938
- log ( debug, fmt ! ( "CLIENT: after client_ch recv ret: '%s'" ,
1939
- ret_val) ) ;
1932
+ debug ! ( "CLIENT: after client_ch recv ret: '%s'" , ret_val) ;
1940
1933
Ok ( ret_val)
1941
1934
}
1942
1935
}
@@ -1946,10 +1939,10 @@ pub mod test {
1946
1939
let write_result_future = sock. write_future ( val) ;
1947
1940
let write_result = write_result_future. get ( ) ;
1948
1941
if result:: is_err ( & write_result) {
1949
- log ( debug, ~ "tcp_write_single: write failed!");
1942
+ debug ! ( "tcp_write_single: write failed!" ) ;
1950
1943
let err_data = result:: get_err ( & write_result) ;
1951
- log( debug, fmt !(" tcp_write_single err name: %s msg: %s",
1952
- err_data. err_name , err_data. err_msg ) ) ;
1944
+ debug ! ( "tcp_write_single err name: %s msg: %s" ,
1945
+ err_data. err_name, err_data. err_msg) ;
1953
1946
// meh. torn on what to do here.
1954
1947
fail ~"tcp_write_single failed";
1955
1948
}
0 commit comments