jjzhang / booth

The Booth Cluster Ticket Manager
GNU General Public License v2.0
16 stars 37 forks source link

Add function:booth client can use the host name. #44

Closed seinocluster2 closed 12 years ago

seinocluster2 commented 12 years ago

This patch also can use the host name when we specify a site in booth client command.

For example

# cat /etc/hosts
192.168.xxx.xxx sitea
192.168.xxx.xxx siteb
# booth client revoke -s siteb -t ticketA
cluster[25373]: 2012/09/22_12:38:51 info: revoke command sent, result will be returned asynchronously, you can get the result from the log files.

Signed-off-by: Yuich SEINO seino.cluster2@gmail.com

seinocluster2 commented 12 years ago

The converted string(host name -> ip) is set to the pointer of "ip_str". So, the result is stored to the passed argument. At least, I tested this behavior in my environment. Do you output a error ?

jjzhang commented 12 years ago

Did you do the unit test on the "else" block? If you pass a real hostname or real IP, they go into the "if" block, that's OK. But if it is not that case, in "else" block, the site_arg is the predefined array, it will not be the content of that hostname. So "ip_str = hostname" cannot work as expected here;) Maybe you should use string copy method to resolve this.

Also, it will be better if you replace AF_INET with the macro BOOTH_PROTO_FAMILY, this is not a must, but just to be aligned with previous code;)

seinocluster2 commented 12 years ago

I see. I added a commit. How is that? I have a question. What kind of c standard do you use? for example, c89, c99, etc. In some cases, I may need to fix the code.