Fix #2758.
Fix #2758.

The problem turned out to be a typo. In certain cases, sync_from() would throw sync_failed_exc_t even if a peer was connected, instead of waiting for metadata from the peer.

I also fixed a couple of minor style issues.

This has been reviewed by @danielmewes.

gavioto/rethinkdb,losywee/rethinkdb,sebadiaz/rethinkdb,KSanthanam/rethinkdb,ajose01/rethinkdb,losywee/rethinkdb,Qinusty/rethinkdb,4talesa/rethinkdb,dparnell/rethinkdb,gavioto/rethinkdb,urandu/rethinkdb,jmptrader/rethinkdb,niieani/rethinkdb,sebadiaz/rethinkdb,tempbottle/rethinkdb,wojons/rethinkdb,ayumilong/rethinkdb,urandu/rethinkdb,mquandalle/rethinkdb,tempbottle/rethinkdb,jmptrader/rethinkdb,yaolinz/rethinkdb,grandquista/rethinkdb,bpradipt/rethinkdb,ajose01/rethinkdb,dparnell/rethinkdb,jesseditson/rethinkdb,urandu/rethinkdb,elkingtonmcb/rethinkdb,mbroadst/rethinkdb,wkennington/rethinkdb,Qinusty/rethinkdb,grandquista/rethinkdb,victorbriz/rethinkdb,mbroadst/rethinkdb,elkingtonmcb/rethinkdb,sbusso/rethinkdb,elkingtonmcb/rethinkdb,grandquista/rethinkdb,mcanthony/rethinkdb,gdi2290/rethinkdb,yaolinz/rethinkdb,alash3al/rethinkdb,catroot/rethinkdb,robertjpayne/rethinkdb,wkennington/rethinkdb,matthaywardwebdesign/rethinkdb,robertjpayne/rethinkdb,greyhwndz/rethinkdb,grandquista/rethinkdb,jesseditson/rethinkdb,urandu/rethinkdb,tempbottle/rethinkdb,mquandalle/rethinkdb,wojons/rethinkdb,bchavez/rethinkdb,lenstr/rethinkdb,niieani/rethinkdb,elkingtonmcb/rethinkdb,greyhwndz/rethinkdb,4talesa/rethinkdb,greyhwndz/rethinkdb,pap/rethinkdb,wujf/rethinkdb,matthaywardwebdesign/rethinkdb,greyhwndz/rethinkdb,sontek/rethinkdb,wkennington/rethinkdb,eliangidoni/rethinkdb,gavioto/rethinkdb,tempbottle/rethinkdb,losywee/rethinkdb,sbusso/rethinkdb,Qinusty/rethinkdb,4talesa/rethinkdb,KSanthanam/rethinkdb,grandquista/rethinkdb,sontek/rethinkdb,KSanthanam/rethinkdb,Qinusty/rethinkdb,greyhwndz/rethinkdb,alash3al/rethinkdb,mcanthony/rethinkdb,marshall007/rethinkdb,AntouanK/rethinkdb,mquandalle/rethinkdb,mbroadst/rethinkdb,mquandalle/rethinkdb,gdi2290/rethinkdb,yakovenkodenis/rethinkdb,marshall007/rethinkdb,wujf/rethinkdb,urandu/rethinkdb,sontek/rethinkdb,bpradipt/rethinkdb,robertjpayne/rethinkdb,sbusso/rethinkdb,4talesa/rethinkdb,Qinusty/rethinkdb,sbusso/rethinkdb,sontek/rethinkdb,alash3al/rethinkdb,niieani/rethinkdb,mquandalle/rethinkdb,jmptrader/rethinkdb,alash3al/rethinkdb,robertjpayne/rethinkdb,bpradipt/rethinkdb,scripni/rethinkdb,JackieXie168/rethinkdb,captainpete/rethinkdb,lenstr/rethinkdb,sontek/rethinkdb,elkingtonmcb/rethinkdb,losywee/rethinkdb,Qinusty/rethinkdb,yaolinz/rethinkdb,losywee/rethinkdb,dparnell/rethinkdb,wojons/rethinkdb,gdi2290/rethinkdb,matthaywardwebdesign/rethinkdb,sbusso/rethinkdb,RubenKelevra/rethinkdb,jmptrader/rethinkdb,grandquista/rethinkdb,pap/rethinkdb,scripni/rethinkdb,jesseditson/rethinkdb,yakovenkodenis/rethinkdb,dparnell/rethinkdb,mcanthony/rethinkdb,Qinusty/rethinkdb,scripni/rethinkdb,gavioto/rethinkdb,gdi2290/rethinkdb,wkennington/rethinkdb,ayumilong/rethinkdb,JackieXie168/rethinkdb,yakovenkodenis/rethinkdb,victorbriz/rethinkdb,rrampage/rethinkdb,Wilbeibi/rethinkdb,bchavez/rethinkdb,eliangidoni/rethinkdb,lenstr/rethinkdb,ajose01/rethinkdb,spblightadv/rethinkdb,matthaywardwebdesign/rethinkdb,losywee/rethinkdb,bchavez/rethinkdb,bchavez/rethinkdb,catroot/rethinkdb,mcanthony/rethinkdb,bpradipt/rethinkdb,sbusso/rethinkdb,rrampage/rethinkdb,catroot/rethinkdb,rrampage/rethinkdb,ajose01/rethinkdb,jesseditson/rethinkdb,mquandalle/rethinkdb,spblightadv/rethinkdb,gavioto/rethinkdb,yakovenkodenis/rethinkdb,matthaywardwebdesign/rethinkdb,mcanthony/rethinkdb,robertjpayne/rethinkdb,bchavez/rethinkdb,JackieXie168/rethinkdb,AntouanK/rethinkdb,wujf/rethinkdb,matthaywardwebdesign/rethinkdb,yaolinz/rethinkdb,KSanthanam/rethinkdb,catroot/rethinkdb,niieani/rethinkdb,bpradipt/rethinkdb,dparnell/rethinkdb,catroot/rethinkdb,marshall007/rethinkdb,yakovenkodenis/rethinkdb,marshall007/rethinkdb,greyhwndz/rethinkdb,Wilbeibi/rethinkdb,KSanthanam/rethinkdb,pap/rethinkdb,elkingtonmcb/rethinkdb,yakovenkodenis/rethinkdb,grandquista/rethinkdb,Qinusty/rethinkdb,ayumilong/rethinkdb,victorbriz/rethinkdb,tempbottle/rethinkdb,spblightadv/rethinkdb,gavioto/rethinkdb,robertjpayne/rethinkdb,greyhwndz/rethinkdb,spblightadv/rethinkdb,yaolinz/rethinkdb,eliangidoni/rethinkdb,mbroadst/rethinkdb,4talesa/rethinkdb,wujf/rethinkdb,catroot/rethinkdb,pap/rethinkdb,mcanthony/rethinkdb,sebadiaz/rethinkdb,pap/rethinkdb,wujf/rethinkdb,captainpete/rethinkdb,captainpete/rethinkdb,alash3al/rethinkdb,ayumilong/rethinkdb,KSanthanam/rethinkdb,scripni/rethinkdb,jmptrader/rethinkdb,grandquista/rethinkdb,niieani/rethinkdb,eliangidoni/rethinkdb,scripni/rethinkdb,rrampage/rethinkdb,marshall007/rethinkdb,victorbriz/rethinkdb,pap/rethinkdb,bpradipt/rethinkdb,sebadiaz/rethinkdb,RubenKelevra/rethinkdb,RubenKelevra/rethinkdb,urandu/rethinkdb,RubenKelevra/rethinkdb,wkennington/rethinkdb,grandquista/rethinkdb,AntouanK/rethinkdb,mquandalle/rethinkdb,lenstr/rethinkdb,Wilbeibi/rethinkdb,victorbriz/rethinkdb,wojons/rethinkdb,tempbottle/rethinkdb,bpradipt/rethinkdb,RubenKelevra/rethinkdb,sontek/rethinkdb,4talesa/rethinkdb,victorbriz/rethinkdb,captainpete/rethinkdb,wojons/rethinkdb,dparnell/rethinkdb,spblightadv/rethinkdb,ayumilong/rethinkdb,ajose01/rethinkdb,Qinusty/rethinkdb,elkingtonmcb/rethinkdb,jmptrader/rethinkdb,sebadiaz/rethinkdb,lenstr/rethinkdb,robertjpayne/rethinkdb,tempbottle/rethinkdb,niieani/rethinkdb,RubenKelevra/rethinkdb,ayumilong/rethinkdb,scripni/rethinkdb,bchavez/rethinkdb,wojons/rethinkdb,4talesa/rethinkdb,ajose01/rethinkdb,elkingtonmcb/rethinkdb,JackieXie168/rethinkdb,eliangidoni/rethinkdb,sebadiaz/rethinkdb,gavioto/rethinkdb,marshall007/rethinkdb,bchavez/rethinkdb,gdi2290/rethinkdb,wkennington/rethinkdb,wujf/rethinkdb,mquandalle/rethinkdb,ajose01/rethinkdb,AntouanK/rethinkdb,Wilbeibi/rethinkdb,captainpete/rethinkdb,lenstr/rethinkdb,captainpete/rethinkdb,gdi2290/rethinkdb,rrampage/rethinkdb,JackieXie168/rethinkdb,wkennington/rethinkdb,mbroadst/rethinkdb,wojons/rethinkdb,dparnell/rethinkdb,scripni/rethinkdb,AntouanK/rethinkdb,jesseditson/rethinkdb,captainpete/rethinkdb,JackieXie168/rethinkdb,rrampage/rethinkdb,wkennington/rethinkdb,wujf/rethinkdb,jmptrader/rethinkdb,marshall007/rethinkdb,JackieXie168/rethinkdb,wojons/rethinkdb,eliangidoni/rethinkdb,JackieXie168/rethinkdb,Wilbeibi/rethinkdb,dparnell/rethinkdb,KSanthanam/rethinkdb,victorbriz/rethinkdb,rrampage/rethinkdb,jmptrader/rethinkdb,matthaywardwebdesign/rethinkdb,RubenKelevra/rethinkdb,gdi2290/rethinkdb,alash3al/rethinkdb,4talesa/rethinkdb,yakovenkodenis/rethinkdb,sontek/rethinkdb,spblightadv/rethinkdb,yaolinz/rethinkdb,yakovenkodenis/rethinkdb,jesseditson/rethinkdb,marshall007/rethinkdb,eliangidoni/rethinkdb,niieani/rethinkdb,greyhwndz/rethinkdb,gavioto/rethinkdb,rrampage/rethinkdb,losywee/rethinkdb,ayumilong/rethinkdb,sbusso/rethinkdb,AntouanK/rethinkdb,matthaywardwebdesign/rethinkdb,JackieXie168/rethinkdb,KSanthanam/rethinkdb,ayumilong/rethinkdb,AntouanK/rethinkdb,yaolinz/rethinkdb,alash3al/rethinkdb,scripni/rethinkdb,tempbottle/rethinkdb,losywee/rethinkdb,pap/rethinkdb,sbusso/rethinkdb,Wilbeibi/rethinkdb,alash3al/rethinkdb,sebadiaz/rethinkdb,bpradipt/rethinkdb,mbroadst/rethinkdb,niieani/rethinkdb,ajose01/rethinkdb,mcanthony/rethinkdb,mbroadst/rethinkdb,eliangidoni/rethinkdb,bchavez/rethinkdb,eliangidoni/rethinkdb,robertjpayne/rethinkdb,RubenKelevra/rethinkdb,mbroadst/rethinkdb,urandu/rethinkdb,lenstr/rethinkdb,jesseditson/rethinkdb,AntouanK/rethinkdb,sebadiaz/rethinkdb,catroot/rethinkdb,urandu/rethinkdb,spblightadv/rethinkdb,lenstr/rethinkdb,jesseditson/rethinkdb,victorbriz/rethinkdb,dparnell/rethinkdb,mbroadst/rethinkdb,catroot/rethinkdb,bpradipt/rethinkdb,spblightadv/rethinkdb,captainpete/rethinkdb,Wilbeibi/rethinkdb,pap/rethinkdb,yaolinz/rethinkdb,robertjpayne/rethinkdb,bchavez/rethinkdb,sontek/rethinkdb,mcanthony/rethinkdb,Wilbeibi/rethinkdb