[Unison-hackers] [unison-svn] r407 - branches/2.32/src
vouillon@seas.upenn.edu
vouillon at seas.upenn.edu
Fri Jan 22 05:26:14 EST 2010
Author: vouillon
Date: 2010-01-22 05:26:14 -0500 (Fri, 22 Jan 2010)
New Revision: 407
Modified:
branches/2.32/src/RECENTNEWS
branches/2.32/src/copy.ml
branches/2.32/src/mkProjectInfo.ml
branches/2.32/src/osxsupport.c
branches/2.32/src/props.ml
branches/2.32/src/remote.ml
Log:
Fixes to the stable release:
* Fixed bug which made Unison ignore finder information and resource
fork when compiled to 64bit on Mac OSX.
* IPV6, socket mode: properly deal with Unix errors, so that Unison
correctly falls back to IPV4 if the kernel does not support IPV6
* copyprog: use better rsync options
Modified: branches/2.32/src/RECENTNEWS
===================================================================
--- branches/2.32/src/RECENTNEWS 2010-01-22 09:52:57 UTC (rev 406)
+++ branches/2.32/src/RECENTNEWS 2010-01-22 10:26:14 UTC (rev 407)
@@ -1,3 +1,13 @@
+CHANGES FROM VERSION 2.32.66
+
+Fixes to the stable release:
+* Fixed bug which made Unison ignore finder information and resource
+ fork when compiled to 64bit on Mac OSX.
+* IPV6, socket mode: properly deal with Unix errors, so that Unison
+ correctly falls back to IPV4 if the kernel does not support IPV6
+* copyprog: use better rsync options
+
+-------------------------------
CHANGES FROM VERSION 2.32.52
* GTK UI: Unison now take into account the arguments given (including
Modified: branches/2.32/src/copy.ml
===================================================================
--- branches/2.32/src/copy.ml 2010-01-22 09:52:57 UTC (rev 406)
+++ branches/2.32/src/copy.ml 2010-01-22 10:26:14 UTC (rev 407)
@@ -506,7 +506,7 @@
(****)
let copyprog =
- Prefs.createString "copyprog" "rsync --inplace --compress"
+ Prefs.createString "copyprog" "rsync --partial --inplace --compress"
"!external program for copying large files"
("A string giving the name of an "
^ "external program that can be used to copy large files efficiently "
@@ -515,7 +515,7 @@
^ "options---most users should not need to change it.")
let copyprogrest =
- Prefs.createString "copyprogrest" "rsync --partial --inplace --compress"
+ Prefs.createString "copyprogrest" "rsync --partial --append-verify --compress"
"!variant of copyprog for resuming partial transfers"
("A variant of {\\tt copyprog} that names an external program "
^ "that should be used to continue the transfer of a large file "
Modified: branches/2.32/src/mkProjectInfo.ml
===================================================================
--- branches/2.32/src/mkProjectInfo.ml 2010-01-22 09:52:57 UTC (rev 406)
+++ branches/2.32/src/mkProjectInfo.ml 2010-01-22 10:26:14 UTC (rev 407)
@@ -120,3 +120,4 @@
+
Modified: branches/2.32/src/osxsupport.c
===================================================================
--- branches/2.32/src/osxsupport.c 2010-01-22 09:52:57 UTC (rev 406)
+++ branches/2.32/src/osxsupport.c 2010-01-22 10:26:14 UTC (rev 407)
@@ -33,12 +33,12 @@
CAMLlocal3(res, fInfo, length);
int retcode;
struct attrlist attrList;
- unsigned long options = 0;
+ unsigned long options = FSOPT_REPORT_FULLSIZE;
struct {
- unsigned long length;
- char finderInfo [32];
- off_t rsrcLength;
- } attrBuf;
+ u_int32_t length;
+ char finderInfo [32];
+ off_t rsrcLength;
+ } __attribute__ ((packed)) attrBuf;
attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
attrList.reserved = 0;
@@ -58,10 +58,10 @@
if (Bool_val (need_size)) {
if (attrBuf.length != sizeof attrBuf)
- unix_error (EOPNOTSUPP, "getattrlist", path);
+ unix_error (EINVAL, "getattrlist", path);
} else {
- if (attrBuf.length < sizeof (unsigned long) + 32)
- unix_error (EOPNOTSUPP, "getattrlist", path);
+ if (attrBuf.length != sizeof (u_int32_t) + 32)
+ unix_error (EINVAL, "getattrlist", path);
}
fInfo = alloc_string (32);
@@ -92,9 +92,9 @@
struct attrlist attrList;
unsigned long options = 0;
struct {
- unsigned long length;
- char finderInfo [32];
- } attrBuf;
+ u_int32_t length;
+ char finderInfo [32];
+ } __attribute__ ((packed)) attrBuf;
attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
attrList.reserved = 0;
Modified: branches/2.32/src/props.ml
===================================================================
--- branches/2.32/src/props.ml 2010-01-22 09:52:57 UTC (rev 406)
+++ branches/2.32/src/props.ml 2010-01-22 10:26:14 UTC (rev 407)
@@ -485,7 +485,7 @@
let toString t = Util.time2string (extract t)
let syncedPartsToString t = match t with
- Synced _ -> toString t
+ Synced _ -> Format.sprintf "%s (%f)" (toString t) (extract t)
| NotSynced _ -> ""
let iCanWrite p =
Modified: branches/2.32/src/remote.ml
===================================================================
--- branches/2.32/src/remote.ml 2010-01-22 09:52:57 UTC (rev 406)
+++ branches/2.32/src/remote.ml 2010-01-22 10:26:14 UTC (rev 407)
@@ -845,29 +845,96 @@
let targetHostEntry = Unix.gethostbyname host in
targetHostEntry.Unix.h_addr_list.(0)
+let printAddr host addr =
+ match addr with
+ Unix.ADDR_UNIX s ->
+ assert false
+ | Unix.ADDR_INET (s, p) ->
+ Format.sprintf "%s[%s]:%d" host (Unix.string_of_inet_addr s) p
+
+let rec findFirst f l =
+ match l with
+ [] -> None
+ | x :: r -> match f x with
+ None -> findFirst f r
+ | Some _ as v -> v
+
+let buildSocket host port kind =
+ let attemptCreation ai =
+ try
+ let socket =
+ Unix.socket ai.Unix.ai_family ai.Unix.ai_socktype ai.Unix.ai_protocol
+ in
+ try
+ begin match kind with
+ `Connect ->
+ (* Connect to the remote host *)
+ Unix.connect socket ai.Unix.ai_addr
+ | `Bind ->
+ (* Allow reuse of local addresses for bind *)
+ Unix.setsockopt socket Unix.SO_REUSEADDR true;
+ (* Bind the socket to portnum on the local host *)
+ Unix.bind socket ai.Unix.ai_addr;
+ (* Start listening, allow up to 1 pending request *)
+ Unix.listen socket 1
+ end;
+ Some socket
+ with Unix.Unix_error _ as e ->
+ Unix.close socket;
+ raise e
+ with Unix.Unix_error (error, _, _) ->
+ begin match error with
+ Unix.EAFNOSUPPORT | Unix.EPROTONOSUPPORT | Unix.EINVAL ->
+ ()
+ | _ ->
+ let msg =
+ match kind with
+ `Connect ->
+ Printf.sprintf "Can't connect to server %s: %s\n"
+ (printAddr host ai.Unix.ai_addr)
+ (Unix.error_message error)
+ | `Bind ->
+ Printf.sprintf
+ "Can't bind socket to port %s at address [%s]: %s\n"
+ port
+ (match ai.Unix.ai_addr with
+ Unix.ADDR_INET (addr, _) -> Unix.string_of_inet_addr addr
+ | _ -> assert false)
+ (Unix.error_message error)
+ in
+ Util.warn msg
+ end;
+ None
+ in
+ let options =
+ match kind with
+ `Connect -> [ Unix.AI_SOCKTYPE Unix.SOCK_STREAM ]
+ | `Bind -> [ Unix.AI_SOCKTYPE Unix.SOCK_STREAM ; Unix.AI_PASSIVE ]
+ in
+ match
+ findFirst attemptCreation (Unix.getaddrinfo host port options)
+ with
+ Some socket ->
+ socket
+ | None ->
+ let msg =
+ match kind with
+ `Connect ->
+ Printf.sprintf
+ "Failed to connect to the server on host %s:%s" host port
+ | `Bind ->
+ if host = "" then
+ Printf.sprintf "Can't bind socket to port %s" port
+ else
+ Printf.sprintf "Can't bind socket to port %s on host %s"
+ port host
+ in
+ raise (Util.Fatal msg)
+
let buildSocketConnection host port =
Util.convertUnixErrorsToFatal "canonizeRoot" (fun () ->
- let rec loop = function
- [] ->
- raise (Util.Fatal
- (Printf.sprintf
- "Can't find the IP address of the server (%s:%s)" host
- port))
- | ai::r ->
- (* create a socket to talk to the remote host *)
- let socket = Unix.socket ai.Unix.ai_family ai.Unix.ai_socktype ai.Unix.ai_protocol in
- begin try
- Unix.connect socket ai.Unix.ai_addr;
- initConnection socket socket
- with
- Unix.Unix_error (error, _, reason) ->
- (if error != Unix.EAFNOSUPPORT then
- Util.warn
- (Printf.sprintf
- "Can't connect to server (%s:%s): %s" host port reason);
- loop r)
- end
- in loop (Unix.getaddrinfo host port [ Unix.AI_SOCKTYPE Unix.SOCK_STREAM ]))
+ let socket = buildSocket host port `Connect in
+ initConnection socket socket)
let buildShellConnection shell host userOpt portOpt rootName termInteract =
let remoteCmd =
@@ -1159,38 +1226,7 @@
let host = match hostOpt with
Some host -> host
| None -> "" in
- let rec loop = function
- [] -> raise (Util.Fatal
- (if host = "" then
- Printf.sprintf "Can't bind socket to port %s" port
- else
- Printf.sprintf "Can't bind socket to port %s on host %s" port host))
- | ai::r ->
- (* Open a socket to listen for queries *)
- let socket = Unix.socket ai.Unix.ai_family ai.Unix.ai_socktype
- ai.Unix.ai_protocol in
- begin try
- (* Allow reuse of local addresses for bind *)
- Unix.setsockopt socket Unix.SO_REUSEADDR true;
- (* Bind the socket to portnum on the local host *)
- Unix.bind socket ai.Unix.ai_addr;
- (* Start listening, allow up to 1 pending request *)
- Unix.listen socket 1;
- socket
- with
- Unix.Unix_error (error, _, reason) ->
- (if error != Unix.EAFNOSUPPORT then
- Util.msg
- "Can't bind socket to port %s at address [%s]: %s\n"
- port
- (match ai.Unix.ai_addr with
- Unix.ADDR_INET (addr, _) -> Unix.string_of_inet_addr addr
- | _ -> assert false)
- (Unix.error_message error);
- loop r)
- end in
- let listening = loop (Unix.getaddrinfo host port [ Unix.AI_SOCKTYPE
- Unix.SOCK_STREAM ; Unix.AI_PASSIVE ]) in
+ let listening = buildSocket host port `Bind in
Util.msg "server started\n";
while
(* Accept a connection *)
More information about the Unison-hackers
mailing list