Added synchronization in link logic to prevent relinking races.
Added synchronization in link logic to prevent relinking races.

There is a general pattern in the `SocketManager` in which most methods
will grab the mutex and then check if the socket to manage exists in
the `SocketManager`s mapping.  If the socket does not exist, the
`SocketManager` silently returns.

This adds similar logic inside two critical sections of the `link`
codepath.  If there are multiple calls to `link` in-flight at once,
this prevents sockets from being leaked into unmanaged callback loops.

Review: https://reviews.apache.org/r/52181/

Aman-Jain-14/customizedMesos,reneploetz/mesos,yuquanshan/customizedMesos,zmalik/mesos,gsantovena/mesos,craimbert/mesos,asamerh4/mesos,zmalik/mesos,asamerh4/mesos,craimbert/mesos,reneploetz/mesos,dforsyth/mesos,chhsia0/mesos,gsantovena/mesos,neilconway/mesos,verizonlabs/mesos,zmalik/mesos,kaysoky/mesos,kaysoky/mesos,craimbert/mesos,jpeach/mesos,verizonlabs/mesos,yuquanshan/customizedMesos,zmalik/mesos,verizonlabs/mesos,asamerh4/mesos,abudnik/mesos,dforsyth/mesos,chhsia0/mesos,neilconway/mesos,Gilbert88/mesos,gsantovena/mesos,kaysoky/mesos,zmalik/mesos,yuquanshan/customizedMesos,Gilbert88/mesos,verizonlabs/mesos,verizonlabs/mesos,andschwa/mesos,abudnik/mesos,jpeach/mesos,zmalik/mesos,jpeach/mesos,reneploetz/mesos,andschwa/mesos,chhsia0/mesos,kaysoky/mesos,kaysoky/mesos,reneploetz/mesos,reneploetz/mesos,Aman-Jain-14/customizedMesos,Gilbert88/mesos,dforsyth/mesos,Gilbert88/mesos,gsantovena/mesos,chhsia0/mesos,andschwa/mesos,reneploetz/mesos,chhsia0/mesos,kaysoky/mesos,Aman-Jain-14/customizedMesos,yuquanshan/customizedMesos,neilconway/mesos,kaysoky/mesos,abudnik/mesos,gsantovena/mesos,asamerh4/mesos,neilconway/mesos,verizonlabs/mesos,andschwa/mesos,jpeach/mesos,yuquanshan/customizedMesos,asamerh4/mesos,andschwa/mesos,chhsia0/mesos,dforsyth/mesos,andschwa/mesos,reneploetz/mesos,craimbert/mesos,abudnik/mesos,neilconway/mesos,craimbert/mesos,asamerh4/mesos,dforsyth/mesos,Aman-Jain-14/customizedMesos,asamerh4/mesos,Aman-Jain-14/customizedMesos,verizonlabs/mesos,neilconway/mesos,andschwa/mesos,jpeach/mesos,craimbert/mesos,Aman-Jain-14/customizedMesos,craimbert/mesos,abudnik/mesos,zmalik/mesos,Gilbert88/mesos,Gilbert88/mesos,yuquanshan/customizedMesos,Gilbert88/mesos,Aman-Jain-14/customizedMesos,dforsyth/mesos,chhsia0/mesos,dforsyth/mesos,abudnik/mesos,abudnik/mesos,gsantovena/mesos,jpeach/mesos,neilconway/mesos,gsantovena/mesos,yuquanshan/customizedMesos,jpeach/mesos